- Home /
Issue with Lerp and rigidbody in Unity5
I had a project in Unity4.6 in which you can move an object to left or right (a 3D project, not 2D). When changing direction, I had the object rotating smoothly with Quaternion.Lerp. But I recently tried using the project in Unity5, and everything is fine except for this. Actually the object, after several moves, or falling a bit on the ground, or also having a force applied, was continuously rotating (on all axis) even if the player then does nothing (not moving left nor right) and the object being alone on the ground, etc.
I should note that I have freeze rotation on Y and Z checked, but the object still rotates around those axis too.
I checked and when this happens, no lerp is applying on its rotation, but there is an angularVelocity that remains continuously. The most interesting is that if I remove all calls to Lerp, it seems that it doesn't happen anymore, and no rotation is then applied on freezed axis, as it should be.
Plus, when it's rotating like this, if I change anything in the rigidbody component in the editor, like even unchecking a freeze checkbox, removing gravity, etc. the rotation stops completely.
So i thought, maybe now I can't use Lerp and the rigidbody as I did in Unity4.6 (in 4.6. it was working, no continuous rotations), maybe due to the new physics engine. Which could mean I had written my code not so well.
Anyway, does anyone have an idea why sometimes the object keeps on rotating on its own, and how can I maybe force the continuous rotations to stop? Thanks!
It's been hours that I try things, and I just found: this thread right after posting this question... Increasing angular drag seems to fix most of the continuous rotation issue. I'm still interested if anyone can explain why this happens...
I experienced a similar issue.
I used AddForce on a rigidbody cube for 1 frame, (0,1,0,Force$$anonymous$$ode.Impulse).
The cube shot into the air and started accelerating at a ridiculous speed.
Tried a fresh project to test, couldn't recreate. Went back to other project, working normally now.
Your answer
Follow this Question
Related Questions
Lerp to target position in X amount of time 2 Answers
If a rigidbody is attached, should you always use AddTorque/AddRelative force for rotation/movement? 1 Answer
Position of skinned mesh with rigidbody on bones. 1 Answer
Issues moving rigidbody with animation(C#) 1 Answer
Kinematic rigidbodies collision 0 Answers