I'm trying to simulate a ship in 3D space using a RigidBody, but I'm having a hard time figuring it out. My goal is to have all movement come as the result of physics calculations involving forces that have their source in the ship itself in the form of various thrusters. I need movement and rotation in all three axes as the result of player input, calculated as physics, so pure translations don't cut it.
The code below seems to work for applying thrust forces to the RigidBody right up until it rotates, at which point the forces applied no longer correspond to the orientation of the object in 3D space:
var thrust_total = Vector3(0, 0, 0)
thrust_total += thrust_forward
thrust_total += thrust_backward
thrust_total += thrust_left
thrust_total += thrust_right
thrust_total += thrust_up
thrust_total += thrust_down
apply_impulse(Vector3(0, 0, 0), thrust_total * delta)
How do I translate between local forces (for example, the player applies the ship's main rear thrusters in an attempt to get the ship moving forward relative to it's own orientation in space) and global forces (the way Godot seems to currently handle 3D forces)?