- Edited
I'm working on a 2.5D game in Godot version 4.1.stable. In my code, I have a character body that I want to rotate based on input. I'm using a Vector3i variable called current to store the rotation angles for the x-axis and y-axis. The problem is that the rotations don't seem to be applied correctly. When I print the current variable, it always shows as (0, 0, 0).
My code:
extends CharacterBody3D
var current = Vector3i.ZERO
var count = 0
func rotation(rotate_x: bool, key: String, angle: int,):
if rotate_x:
if Input.is_action_pressed(key):
current.x = angle
rotate_x(angle)
else:
if Input.is_action_pressed(key):
current.y = angle
rotate_y(angle)
func rotating():
rotation(true, "Right", 90)
rotation(false, "Left", -90)
rotation(true, "Up", 90)
rotation(false, "Down", -90)
#Output the inputs
func _input(event):
if Input.is_anything_pressed():
print(current)
The output:
(0, 0, 0)