# Quaternion.Euler is not smooth

Hello, I’m making strategy game and want to implement changing the rotation of the camera based on how far or how close to the ground the camera is (50 degrees for close, 90 degrees for outmost far). But my implementation of this function is not very smooth and the camera changes its rotation in very visible steps. I tried to do it other way but I’m not that experienced with Quaternions. This is my code:

``````// Moving camera up
if (Input.GetAxis("Mouse ScrollWheel") < 0 && (newZoomPosition.y + zoomSpeed.y) <= upperZoomBorder)
{
newZoomPosition += zoomSpeed;
}
// Moving camera down
if (Input.GetAxis("Mouse ScrollWheel") > 0 && (newZoomPosition.y - zoomSpeed.y) >= lowerZoomBorder)
{
newZoomPosition -= zoomSpeed;
}
RotationStep = (newZoomPosition.y - lowerZoomBorder) / (upperZoomBorder - lowerZoomBorder);

cameraTransform.localRotation = Quaternion.Slerp(lowerRotation.rotation, upperRotation.rotation, RotationStep);
``````

Well, the mouse wheel input is the one that comes in steps. You just pass those “steps” on. If you want a smooth transition between two wheel notches you have to use a second variable. If you only want to smooth the rotation you would use “RotationStep” as a “target” value and then smoothly move the current rotation (the new variable I’ve mentioned) towards the target value.

However since you probably also move the camera to your newZoomPosition this movement would also be “steppy”. So it’s probably better to simply smooth this transision. So when simply using “newZoomPosition” as the “target” value you probably just want to do something like that:

``````currentPosition = Vector3.MoveTowards(currentPosition, newZoomPosition, smooth * Time.deltaTime);
RotationStep = (currentPosition.y - lowerZoomBorder) / (upperZoomBorder - lowerZoomBorder);
``````

We don’t see if and where you update your camera position but you would use “currentPosition” instead of “newZoomPosition”.

Note instead of MoveTowards you could also abuse Vector3.Lerp to do a non linear fade out:

``````currentPosition = Vector3.Lerp(currentPosition, newZoomPosition, smooth * Time.deltaTime);
``````

Well you need a time component to use in update with a Slerp, right?