Hello,

In a 2d top down space game, I'm attempting to make a space ship move using input vectors (using heartbeast's ARPG tutorial). The ship rotates using the look_at function and faces the mouse cursor. How would I go about making the input vectors relative to the ship's rotation?

``````var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("Right") - Input.get_action_strength("Left")
input_vector.y = Input.get_action_strength("Backward") - Input.get_action_strength("Forward")
input_vector = input_vector.normalized()

if input_vector!= Vector2.ZERO:
velocity += input_vector * acceleration * delta
velocity = velocity.clamped(max_move_speed * delta)

else:
velocity = velocity.move_toward(Vector2.ZERO, friction * delta)

move_and_slide(velocity * delta)
``````
Godot version 3.5.1
in Engine

``````velocity += transform.basis.x * your_movement_calculation
``````

(or change to suit whatever is considered forward; it could be `basis.y` in your game)

You don't need `delta` in `move_and_slide`, see here: https://docs.godotengine.org/en/stable/tutorials/physics/using_kinematic_body_2d.html#move-and-slide

by (834 points)

Thanks for the response! I was able to use transform.basis_xform by doing the following:

``````input_vector = transform.basis_xform(input_vector).rotated(\$Sprite.rotation)
``````

(had to use my sprite's rotation since it is rotated 90 degrees so that using `look_at` to my global mouse position works correctly)

But this seemed to do the trick! Thanks for the catch on `delta` in `move_and_slide`, that's very helpful.