- Home /
Slow LookAt
So I have a Vector3 point. I want to know how I could get my player to look at that point. Not just look at immediately (LookAt()), but slowly turn to the point until it is looking directly at it.
Any advice on where to start?
Answer by sHTiF · Sep 14, 2011 at 02:07 AM
I am sure this was answered numerous times, but the simple answer is:
//calculate the rotation needed neededRotation = Quaternion.LookRotation(targetPosition - yourPosition);
//use spherical interpollation over time interpolatedRotation = Quaternion.Slerp(yourRotation, neededRotation, Time.deltaTime * rotationSpeed);
Ah! thanks, i couldn't figure out of to calculate the needed rotation. :)
Thanks for the answer @sHTiF I couldn't find that answer anywhere else.
This was incredibly helpful. I'm writing my own AI and wasn't happy with using Transform.LookAt() and I couldn't remember how to go about it with quaternions. Interesting that it's basically the same way I have my enemy chasing the player via transform.position. Occam's razor I suppose. Thanks!
Your answer
![](https://koobas.hobune.stream/wayback/20220612212422im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Lookat, FromToRotation and LookRotation? 3 Answers
How can I get local 2d Velocity? 2 Answers
Quad Object needs to look at character rotating one Axis 0 Answers
Player looking script 0 Answers
Rotate my torso in vertical axis towards crosshair (target) 0 Answers