```
float hMovement = Input.GetAxis("Horizontal") * movementSpeed /2;
float vMovement = Input.GetAxis("Vertical") * movementSpeed;
if (hMovement > 15 && 30 > transform.localRotation.eulerAngles.y ){
transform.rotation *= Quaternion.Euler(0,2,0);
}
if (hMovement < -15 && -30 < transform.localRotation.eulerAngles.y){
transform.rotation *= Quaternion.Euler(0,-2,0);
}
if (hMovement < 15 && hMovement > -15 ){
transform.rotation = Quaternion.Euler(0,0,0);
}
```

I am making an 3D endlessrunner in 3rd person view.
I have a problem. I want that my character rotates up to 30 degrees into the direction its moving to. And this in smooth roatations. this code kind of works. To the right side(the first if clause) it locks at 30 degrees. But at the left side it keeps spining. But why???

Never read from eulerAngles if you intend to do arithmetic on them.

Keep your own rotation and use it to drive the rotation.

https://starmanta.gitbooks.io/unitytipsredux/content/second-question.html

If you need smooth rotation (or smooth ANYTHING), this approach always works:

Smoothing movement between any two particular values:

The problem is the choice of integer values for lanes. They can only either be lane 0, 1 or 2. They can’t be in between round numbers. It needs to be a floating point value so that it can be between lanes.
This type of question comes up so universally I have finally just made a sample package to demonstrate the basic concept. Read my first post above and see if you can correlate each part of the code to the steps indicated.
Code located here: SmoothMovement.cs · GitHub
6430100–719246–SmoothMo…
You have currentQuantity and desiredQuantity.

only set desiredQuantity
the code always moves currentQuantity towards desiredQuantity
read currentQuantity for the smoothed value
Works for floats, Vectors, Colors, Quaternions, anything continuous or lerp-able.

The code: SmoothMovement.cs · GitHub