# How to, restrict Quaternion.Slerp to the Y axis?

Hello fellow uniteres!

I have a third person game where the camera is free to rotate around when the player is not moving. And when the player is moving the players Y axis lines with the cameras Y axis, but when doing so the player “snaps” to the cameras Y axis.

I want to make this smooth and therefor considering using Quaternion.Slerp, but the problem using Quaternion.Slerp is that it is “Slerping” all axis X, Y, Z, but as said I only want to “Slerp” the Y axis. Is this possible(It most likely, but I do not know how to)
I have tried Mathf.Clamp, but that causes “shaky” movements and slow fall through the floor.

The current code I use for the rotation right now is this(small sample only):

``````  var GameCam : Transform; //Camera goes here.

if(Input.GetAxisRaw("Vertical") > 0.1 && !Input.GetAxisRaw("Horizontal"))
{
transform.eulerAngles.y = GameCam.eulerAngles.y; // This is used for the rotation
transform.Translate(0,0,Input.GetAxisRaw("Vertical")/20);//Movement no need to look at that.
}
``````

So can you please tell me a way to restricting “Slerping” to the Y axis only. I will be greatfull!

yourRotationQuaternion = Quaternion.Slerp(to, from, time);

yourRotationQuaternion = Quaternion.Euler(new Vector3(0f, yourRotationQuaternion.eulerAngles.y, 0f));

done like dinner

After the Quaternion.Slerp statment

transform.localEulerAngles = Vector3(0, transform.localEulerAngles.y, 0);

transform.rotation.y = Quaternion.Slerp(bla bla bla).y;