0 votes

Hey, I have a spaceship that needs to be able to move around the world. Currently the ship can accelerate in any direction, and rotate to face different directions, but the RigidBody obviously doesn't like the rotation, as it stops whenever I rotate the ship, and when I stop rotating it continues moving at a slower velocity.

So, it seems like I have to apply torque to the RigidBody as to not interfere with its own physics. But there are only functions for applying torque around the global axes! How do I apply torque around the ship's local axes?

in Engine by (12 points)

If I get the docs right then you actually pass the vector3 of the axis around which you want to rotate (multiplied by the force presumably). So try using a local axis for that. I.e. transform.basis.y

Oh! I immediately just assumed the torque was in global euler angles, for some reason, since the docs of add_torque don't mention that torque is also the axis, and so I didn't even bother to look at apply_torque_impulse. Thanks for pointing that out.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.