Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Gilberticus |
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)