|
Hi, The player can use the up and down arrow keys to give the rigidbody momentum (the keys enable and disable thrust). This acts like acceleration, by calling rigidbody.AddRelativeForce . This was exactly what I wanted. I then went and made it so the player could turn the rigidbody, by implementing rigidbody.AddRelativeTorque . This did not achieve the desired effect, as the directional vector already in place caused the rigidbody to drift. My question is: how do I rotate this rigidbody such that momentum rotates with the object? More precisely, is there a function that will do it for me, or should I use the math component to manually rotate the force vector on the rigidbody? Thanks, EDIT:
Thanks for the help!
(comments are locked)
|
|
It's not physical, but you could just rotate the velocity vector and reapply it. This typically results in more intuitive, better feeling controls. EDIT The easiest way to do this is maintain a transform as the current intended velocity vector. Rotate the transform when the player rotates, and then call Transform.forward. Multiply that by the Rigidbody.velocity.magnitude and reassign that to Rigidbody.velocity. That is what I'd meant when I mentioned manually rotating the vector. I wanted to make sure there wasn't a function that would do this for me instead. On the other hand, I have absolutely no idea what the best way to rotate a vector is given the API (I'm new here!).
Jan 28 '10 at 09:19 PM
CheshireCat
(comments are locked)
|
|
It is not physically acurate to do this, of course, but you can acheive it easily by rotating the current velocity of the ship.
(comments are locked)
|

Sorry to be dense, but where do you enter the rotation input for this? i.e. if you're using:
turning = Input.GetAxis ("Horizontal") ;
I have a kinematic rigidbody..and I want to do rotate rigidbody in momentum and stop it then. How is that possible??