# Slerp affecting only one axis?

I’m wondering how I can use slerp to move from one position back to default when pressure isn’t kept so far all I can do is reset all the rotations and I don’t want the Y axis to be effected. What I currently have

``````Quaternion startRotation;
Quaternion curRotation;

void Start()
{
startRotation = transform.rotation;
}

if (forwardReverse != 0)
{
ForwardMove(-forwardReverse);
}
else
{
curRotation = transform.rotation;
transform.rotation = Quaternion.Slerp(curRotation, startRotation, resetTime);
}
``````

Instead of using Quaternions, use euler angles.

``````transform.eulerAngles = ...
``````

That way, you can input a Vector3 and deal with only the X, Y, and Z axises. With a Quaternion, you also have to deal with a W axis which is very confusing. So what you can do is this:

``````transform.eulerAngles = new Vector3(Mathf.Lerp(transform.eulerAngles.x, startRotation.x, resetTime), transform.eulerAngles.y, Mathf.Lerp(transform.eulerAngles.z, startRotation.z, resetTime));
``````

As you can see, I am dealing with only 3 axis. The Y axis is kept the same. Lastly, I am individualing lerping the X and Z axises using Mathf.Lerp.

Also, take out the curRotation variable. Change the startRotation data type to a Vector3.
The last thing you need to do is replace line 6 with:

``````startRotation = transform.eulerAngles;
``````