I would like to change a camera's rotation and position from its current position and rotation to a destination position and rotation.
This should happen within a specific time (seconds).
I call this void "pRotateAndPosition" in each Public void Update().
However, I'm having trouble getting the 3rd argument for Lerp (time) correct.
Could anybody tell me where my mistake(s) are?
Thank you.
private void pRotateAndPosition()
{
_TimeElapsed += (Time.deltaTime / TimeInSecondsInWhichWeWantToGetToFinalRotationAndPosition);
if (_TimeElapsed >= TimeInSecondsInWhichWeWantToGetToFinalRotationAndPosition)
{
_StopCallingThisVoid = true;//don't call this anymore
//set the final position and rotation in case we're not completely there yet
_camera.transform.localRotation = Quaternion.Euler(goalRotation);
_camera.transform.localPosition = goalPosition;
return;
}
float fTime = _TimeElapsed;//absolutely not sure about this one
_camera.transform.localRotation = Quaternion.Lerp(_camera.transform.localRotation, Quaternion.Euler(goalRotation), fTime);
_camera.transform.localPosition = Vector3.Lerp(_camera.transform.localPosition, goalPosition, fTime);
}