Godot Version
4.3
Question
I’m working on a game with top down movement and I’d like to know how to hat something to rotate in the direction the joystick is being pushed.
4.3
I’m working on a game with top down movement and I’d like to know how to hat something to rotate in the direction the joystick is being pushed.
You can get the angle of a vector (such as your input direction) with .angle()
and apply that to your rotation
var input_dir: Vector2 = Input.get_vector("left", "right", "up", "down")
rotation = input_dir.angle()
Ok but how do I get the player to rotate towards the angle of the vector?
Is there anything in particular that’s confusing? rotation
is a property of Node2Ds, which changes the rotation of the object and it’s children.
Oh so I just change the rotation to be equivalent to the angle of the vector.
Worked like a charm!
Sorry i dont know much but you can use if Input.is_action_just_pressed(“Left_or_right_or_stuff”)
It works for joysticks too or maybe that’s not what you wanted?