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.