- Home /
Rotation using Quaternion.Lerp
I'm following a tutorial on youtube by unitycookie, he gave the following line of code to look at a target:
gameObject.transform.rotation = Quaternion.Lerp(currentRotation, desiredRotation, Time.deltaTime * turnSpeed);
alas it doesn't seem to work for me, the object does turn but it doesn't face it's target, it's usually about 90 or so degrees off.
Note: it's never exactly 90 degrees off so it's not a consistent error it seems
Just for future reference - here's a tutorial on using Quaternions for a bunch of things including Look Ats when the objects involved don't look down forward by default etc.... UnityGems.com
@whydo ... here's a great example of a customer that deeply needs a Unity Gems Gem ... :-O
http://answers.unity3d.com/questions/332824/acceleration-and-deceleration-of-an-object.html
@whydo .. UG Triumph !! -->
http://answers.unity3d.com/questions/333195/rotate-90-degrees-question.html
you ROC$$anonymous$$ !
Hey did you have any comments on my beginner mistakes article?
holy GOD man ... you did a new article already ?
Now you are just making ordinary people look bad. hang on !!
Answer by Rybo5000 · Oct 15, 2012 at 06:02 AM
Turns out the problem was quite simple, the target wasn't positioned correctly.
It was too small and too far away for it work properly.
Your answer
Follow this Question
Related Questions
A little help with this camera script please? 3 Answers
Finding A Rigidbody's Rotation Speed And Direction 2 Answers
Whats the Difference Between Rotation EulerAngles and Quaternions? 2 Answers
Lerp with raycast hit.normal? 2 Answers
Rotating to Slope 1 Answer