PDA

View Full Version : Physics question in Unity - conserving momentum


Commodore
09-05-2011, 02:23 PM
Hey guys, this is my first post on this site. I'm using unity and I ran into a problem that I don't know how to fix. I have no clue what to search to fix it either so if somebody could link me to a thread explaining it that'd be great!

So lets say I rotate my object on its y axis, If I then make it rotate on its x axis, it'll stop rotating on its y axis completely. How do I conserve the momentum?

Here's the script I'm using in case you're wondering.


function FixedUpdate () {
if (Input.GetKey("left"))
{
rigidbody.AddRelativeTorque (Vector3.up * -10);
}
if (Input.GetKey("up"))
{
rigidbody.AddRelativeTorque (Vector3.forward * 10);
}
}

AeroAstroArtsLtd
09-06-2011, 06:06 PM
I guess your gonna just have to hit the books on this a quick google search for 'bi-directional vector rotation' came up with this page if this helps http://en.wikipedia.org/wiki/Rotation_representation_%28mathematics%29