I have a 3D environment with 2D gameplay. The player controls a rocket with rotate and thrust within the XY plane. The physics-based gameplay necessitates the rocket being a rigidbody. I want it to roll off collision models within the environment, which it does perfectly. But when I hit something at a high velocity, the rocket will be rotated on its local X or Y axis, setting it on an oblong plane rather than the XY plane of the environment.
I thought this code would keep the rotation locked to the local Z axis, but after some testing, I can still disengage the rocket from the XY plane.
What is the answer?
Here is the current script for the rocket:
asked Jan 05 '10 at 10:35 PM
Use a Configurable Joint (see also the class documentation). If you attach it to your rigidbody, you can use it to limit the rotation around any of the axes. Simply set the "Angular X/Y/Z Motion" property to Locked for the axis you want to restrict.