# Rotation snapping to 180 degrees with transform.rotation

I’m directly getting input from my Horizontal axis and assigning it to quaternion.x which is then set as the rotation to my object.
but even the slightest change in the quaternion (less than 0.00001) snaps the rotation to 180 degrees on any axis.
Here’s my code:

``````		steer = Input.GetAxis("Horizontal");
localRotation.x = steer;
transform.rotation = localRotation;
``````

Im trying to get the axis to directly controll the degrees of rotation on x axis.

Alright I have two answers for you.

First, is the one you asked for, using a maximum angle for your object. The drawback with using this one, is that you will not have control over how quickly your Input.GetAxis accellerates to 1 or -1.

``````    float maxAngle = 120;
float steer;

void FixedUpdate ()
{
Quaternion steer;
steer = Quaternion.Euler(Input.GetAxis("Horizontal") * maxAngle, 0,0);
transform.localRotation = steer;
}
``````

This second method simply rotates in the direction you are holding down, based on a fixed speed. Now, you can obviously alter this to your liking with an if statement to measure against the current rotation, so it has the potential to be a better solution if you need that rotation speed.

``````    float rotationSpeed = 10;
float steer;

void FixedUpdate()
{
steer += Input.GetAxis("Horizontal") * rotationSpeed;
transform.localRotation = Quaternion.Euler(steer, 0, 0);
}
``````

Let me know how that goes for you. Good luck!