I have setup a transition of camera between 2 transform, here the result in video: https://youtu.be/rcwQ6KuEfMw

I have the information of the 2 transform: - position (vector3) - rotation (Quaternion)

And I do a Lerp, from Position1 to Position 2, and from Rotation1 to Rotation2:

Vector3 finalPosition = Vector3.Lerp(previousPosition, nextPosition, evaluateValueLerp);
Quaternion finalRotation = Quaternion.Slerp(previousRotation, nextRotation, evaluateValueLerp);

Now the problem is, as you can see in the video: the player target (the car) is lost durring the transition, I would like to keep it always in the view.

How can I manage to do it ?

Thanks you !

  • \$\begingroup\$ you can add a new position between your position A and position B, first translate from A to a new position and from new position to position B. by that way you can easily solve the problem. I am assuming start position as position A and end position as position B. \$\endgroup\$ Sep 5 '19 at 7:52
  • \$\begingroup\$ Add a new position, or a new Transform ? (if I only add a Vector3 position, the rotation will be the same). I am guessing you mean add a Transform, with position & rotation, and do what you say: (do transition from A to X, then from X to B (X being the new rotation) \$\endgroup\$
    – Ugo Hed
    Sep 5 '19 at 9:24
  • \$\begingroup\$ Add a new transform, you need to change position and rotation. \$\endgroup\$ Sep 5 '19 at 9:26
  • \$\begingroup\$ I'd approach it differently - create a gameobject which contains your camera, then parent that gameobject to the car. Rotating the gameobject will make the camera orbit the car, and have it always at a specific location (depending on your camera's local transform). \$\endgroup\$ Feb 10 '20 at 13:08

I would 'move' the camera as you are doing now, but just use LookAt, or LookRotation, to point at the target. Lerping the transform.position should give you a smooth transition to the camera's rotation anyway, without the need to Slerp, but you could add some damping once you've got it working.


Try this

public Transform target;


attach this to camera

  • \$\begingroup\$ You'll need a bit more code there for this to be a valid script. You probably want the transform.LookAt to be inside an Update or LateUpdate method. \$\endgroup\$
    – DMGregory
    Jun 10 '20 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.