In my game the player actuates thrusters with WASD and changes heading with the mouse (or arrow keys). Thrust can be vectored forwards, backwards, and to the sides. My goal is believable acceleration behavior and the ability to change velocity regardless of where the ship is pointed (albeit only in those 4 directions and their diagonals).

I slept through anything and everything mentioning vector math in college, along with most trig. I have something like this each _physics_process().

player_rotation = self.global_rotation
if Input.is_action_pressed("forward"):
     movement_direction += Vector2(sin(player_rotation), cos(player_rotation)) * base_acceleration_forward

...and so forth with the other 3 directions (relative to the ship) that you can exert thrust in. It doesn't do what I'm expecting. Thrust is sometimes, but not always, in the direction the ship is facing. Any idea what's going on?

PS, the line starting with movement_direction is indented as it should be. I'm not sure how to format it so that that shows.

The math is already in Godot. I think you do it like this:

player_rotation = self.global_rotation
if Input.is_action_pressed("forward"):
    movement_direction += Vector2.RIGHT.rotated(player_rotation) * base_acceleration_forward

It depends which way you Sprite is facing by default. I think the convention is to have the head of the ship facing to the right.

    cybereality

    Thank you. I’ll check that out after work. Somehow a lot of googling didn’t turn up any solutions. Must’ve been wording it wrong.

    6 days later

    cybereality

    Observed behavior is identical. The ship will accelerate and decelerate as expected in a certain range of angles, but not at all outside of that range. Acceleration along the x axis seems mostly fine, but not along the y. Any ideas?

    Correction: I was doing something separate in that code which was causing the problem. Think it's all good now.