- Home /
Gently keep object upright
Hi everyone. I'm using RigidBodies and want to keep one upright, but gently (it should be unnoticable to the user) How can I do this?
I have had success with "transform.localRotation.eulerAngles.x = $$anonymous$$athf.SmoothDampAngle(transform.localRotation.eulerAngles.x, 0.0, yVel, 2.0);" but I how can I detect if the object is facing downwards on its local X axis?
Answer by YM_Industries · May 27, 2012 at 11:16 AM
The answer here solved my problem nicely. http://answers.unity3d.com/questions/10425/how-to-stabilize-angular-motion-alignment-of-hover.html
Answer by Oliver Eberlei · Jun 12, 2011 at 11:10 AM
You can freeze the rigidBody's rotation on it's X and Z axis. This way you can still rotate him to look in different directions but he will not fall over.
You can freeze the rotation in the "Contraints" section in the Inspector or the RigidBody component.
I don't want it to be completely frozen, I want it to gradually correct itself.
Answer by Anxo · Jun 12, 2011 at 11:19 AM
you can use this to have the object look up smoothly.
http://answers.unity3d.com/questions/13869/how-do-i-get-smooth-rotation-to-a-point-in-space.html
This solution works with objects that are transformed, but the original question was about objects rotated using physics
Your answer
Follow this Question
Related Questions
F-Zero Game - Collisions/Physics. 1 Answer
Rigidbody enemy Forcemode.VelocityChange 1 Answer
Game Object seems to move on it's own 0 Answers
Collision problems 0 Answers