Input rotation problem

Godot Version

4.2.1

Question

I am trying to make an arrow that points at the direction that you press or on the keyboard or on the joystick how can I do this?

or the angle from one point to another

If the arrow points to the right by default, you can rotate the arrow like this:

var input_vector := Input.get_vector("left", "right", "up", "down")
if input_vector:
    arrow.rotation = input_vector.angle()

You can also rotate the arrow without trigonometry. However, this example also resets the arrow’s scale property.

var input_vector := Input.get_vector("left", "right", "up", "down")
if input_vector:
    input_vector = input_vector.normalized()
    arrow.transform.x = input_vector
    arrow.transform.y = -input_vector.orthogonal()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.