Rotating camera with Quaternion

I am trying to rotate my camera smoothly from one direction to another.

I have been setting my camera rotation with

Cam.newCamRotation = Quaternion.Euler (2, 152,349);

So I am trying to rotate from one rotation to another smoothly. So I made an effort with this adding it to the LateUpdate.

	if (rotatesmooth){		
	newCamRotation = Quaternion.Lerp (Quaternion.Euler(0, 0,180),Quaternion.Euler(2, 152,349), 3f * Time.deltaTime );
	}

It doesn’t seem to do anything except jitter a little bit. The rest of my code is pretty extensive and the mistake may be somewhere else, but I think the issue is the part I am asking about. Anyone have any suggestions?

thanks

What you have here won’t work (Slerp() or Lerp()). There are a couple of different ways to solve your problem depending on what you want.

  1. You can implement a timer. When you fix both the start and end of the rotation, you need the values for the third parameter of Slerp to go from 0 to 1. Values outside this range do nothing. Your current code uses a small, but fluctuating value for the third parameter.

    newCamRotation = Quaternion.Slerp (Quaternion.Euler(0, 0,180),Quaternion.Euler(2, 152,349), fraction );

  2. Use the current rotation as the first parameter. This produces an eased movement:

    newCamRotation = Quaternion.Slerp (newCamRotation,Quaternion.Euler(2, 152,349), speed * Time.deltaTime);

  3. Use the current rotation and change to using Quaternion.RotateTowards(). This produces a movement at a fixed speed.

    newCamRotation = Quaternion.RotateTowards (newCamRotation,Quaternion.Euler(2, 152,349), speed * Time.deltaTime);

Try Slerp