1
\$\begingroup\$

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 !

\$\endgroup\$
  • \$\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\$ – Kartik Shah Sep 5 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 at 9:24
  • \$\begingroup\$ Add a new transform, you need to change position and rotation. \$\endgroup\$ – Kartik Shah Sep 5 at 9:26
0
\$\begingroup\$

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.

\$\endgroup\$

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.