# LookAt different object smoothly in unity3d

As picture depicted my camera moving on path i want to lookAt bath different object smoothly. Currently have tried

trasnform.LooAt(activePath.gameObject.transform);


but it producing jerky result. object suddenly lookAt to next object how to avoid it. I searched and found this sloution but it also not working

var targetRotation = Quaternion.LookRotation(activePath.gameObject.transform.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime);

• Slerp is an interpolation. Delta time must be a ratio of TimeSinceLookingAtLastTarget/TotalTimeDesiredToLookAtNextTarget. If you expect it to take 2 seconds to turn from target A to target B, and it's been .25 seconds, the interpolation ratio should be 0.125. – RobStone May 16 '16 at 15:47

Slerp is an interpolation. The final parameter T must be a ratio of TimeSinceLookingAtLastTarget/TotalTimeDesiredToLookAtNextTarget.

0 <= T <= 1

If you expect it to take 2 seconds to turn from target A to target B, and it's been .25 seconds, the interpolation ratio should be 0.125.

Time.DeltaTime is just the number of seconds in took to process the last frame. It should always be consistently low and won't change much. At 60FPS, that code would leave you looking 1/60th of the way between two targets.

So you will need to know the actual time and how long it should take. When you start the turn, capture

float SecondsToTurn = 2; //adjust this

float TurnStartTime = Time.Time;

Each frame calculate your slerpT as

float slerpT = (Time.Time - TurnStartTime) / SecondsToTurn