- Home /
Quaternion.LookRotation precision error
Hey there!
I'm having a hard time trying to deal with the precision using Quaternion.LookRotation...
Why is this happening? The image it explains for itself. The white line is a Debug line from the rocket transform to the target transform.
Also, there's the piece of code relevant to the Quaternion.LookRotation
Quaternion lookAtTarget = Quaternion.LookRotation(target.position - transform.position);
rigidbody.rotation = Quaternion.Lerp(rigidbody.rotation, lookAtTarget, Time.deltaTime * turnSpeed);
Any hint?
Answer by asafsitner · Jan 22, 2015 at 08:26 AM
You may not want to manipulate the rigidbody's rotation directly as it's supposed to be manipulated via rigidbody.AddTorque.
However, as mentioned in the API reference, if you wish to control the rigidbody's rotation precisely from code you should use rigidbody.MoveRotation. In order to do that smoothly, I suggest you slerp a temporary quaternion in the Update method, then feed it's value to the MoveRotation in the FixedUpdate method.
After a few days trying it, it works like the script that I used before.
I figured out that I need to use a PID but I really don't know how to tweak the values P, I and D. So I'm still stuck...
Your answer
![](https://koobas.hobune.stream/wayback/20220613181145im_/https://answers.unity.com/themes/thub/images/avi.jpg)