|
How do I stabilize the angular motion of a hovering object? I have a hovering vehicle that moves at some distance above the ground, controlled with the arrows keys. The problem is that when it collides with some object (like a building) its rotation gets shifted. When I am moving it after this, it moves according to its local space rotation. How can I cause my Rigidbody to return back to its initial rotation where it is only rotated around the Y axis?
(comments are locked)
|
|
You can use this script (C#) to stabilize your Rigidbody so it returns to an alignment where the local Y axis points upwards:
With the script you can control both how fast the Rigidbody stabilizes and how stable or wobbly the stabilization is. Note: If you only want to stabilize along one axis, you can project the torqueVector onto that axis. For example, to stabilize along the local z (forward) axis only, do this before applying the torque: Thanks, This worked great for me. You are a legend!
Dec 19 '10 at 02:49 AM
YoshieMaster
This worked beautifully for me thanks!
Dec 10 '12 at 07:45 AM
PraetorBlue
Works perfectly for me, thank you !
Mar 31 at 06:55 PM
again
(comments are locked)
|
|
Thank you so much . I am still quite new to 3d math in unity so i am having a hard time to figure out this stuff . Before your solution I actually decided to use Configurable Joint and cancel out angular x,z but the downside of it was that on collisions there was no angular change at all that have made these collisions to look unrealistic . Now that is exactly what I need . Thanks once again !!!!!!! You're welcome! :) Consider in the future to add comments like this using "add comment" to the answer you're commenting on, rather than adding it as a new answer (because your comment is not an answer to the posted question).
Jan 21 '10 at 04:23 PM
runevision ♦♦
(comments are locked)
|
