Problem with Camera Transition (First-person to third-person, with Slerp)

I have this code before the Start() function:

//CAMERAS
public Camera ThirdPerson;
public Camera FirstPerson;
private bool Camerastate = true;
private float time = 5f;

And this code in the Update():

//CAMERAS
		//Sets the Camerastate to the opposite of the current Camerastate
		if(Input.GetKeyDown(KeyCode.Tab))
		{
			Camerastate = !Camerastate;
		}

		if(Camerastate == true)
		{
			transform.position = Vector3.Slerp(transform.position, ThirdPerson.transform.position, time * Smooth);
			transform.rotation = Quaternion.Slerp(transform.rotation, ThirdPerson.transform.rotation, time * Smooth);

			ThirdPerson.enabled = true;
			FirstPerson.enabled = false;
			Debug.Log("Third");
		}
		



		else
		{

			transform.position = Vector3.Slerp(transform.position, FirstPerson.transform.position, time * Smooth);
			transform.rotation = Quaternion.Slerp(transform.rotation, FirstPerson.transform.rotation, time * Smooth);

			
			ThirdPerson.enabled = false;
			FirstPerson.enabled = true;
			Debug.Log("First");
			


		}

The camera goes well from first person to thirdperson when I press “tab”, but it doesn’t go smoothly from thirdperson to firstperson. Anyone can help me with this?
Thank you very much!

I would go about it in a different way to reduce code duplication. (and probably fix your issue)

  • Have one camera and two “marker” gameobjects it can be at
  • When you want to transition to a different mode (first/third person) set a different marker as the goal
  • Make the camera always lerp towards whatever marker is its goal