lookat() issue

I am making a sort of FPS and I need my camera to look at a specific object. I’m using the lookat() method, which does exactly what i want except it does it simply changes my camera rotation from my current to where i want it to look at instantly. Instead I would like for it to perform this rotation over time. Any suggestions?

1 Answer

1

Instead of using lookat() directly, try using an intermediate step-

targetRotation = lookat(whatever);
actualRotation = Quaternion.Slerp(currentRotation, targetRotation, Time.deltaTime * someAmount);

This makes the actual rotation lag behind the target rotation a little, but it should smoothly follow the way you want it to!

You should use Quaternion.LookRotation (assuming whatever is a Transform): targetRotation = Quaternion.LookRotation(whatever.position); Since LookRotation asks for a point, you must pass the target's transform.position to make it look at the target object.