rotating my player

Hi guys

I’m rotating my player to the left and right using this code:

if (Input.GetAxis("Horizontal"))
	{
		myTarget.rotation.y += Input.GetAxis("Horizontal") * Time.deltaTime  * 2;
	}

The problem is that the increments of the input.getAxis gets smaller and smaller and eventially the player doesn’t turn at all any more. How can I change this to make my player turn at a constant speed?

Thanks

have a look at transform.rotate in script reference

Like appels said, you’ll probably want to use Transform.rotate for this.

Anyway, I’m beginning to think that the ‘Transform.rotation’ confusion is epidemic :slight_smile: I think this is the fourth or fifth post I’ve seen in the last week where someone has been trying to treat the elements of the ‘rotation’ quaternion as angles.

As I mentioned in another, similar thread, I’m not sure what exactly Unity does under the hood when you modify the rotation elements directly like that, but I’m guessing that after the modification is applied, the result is normalized. So, I would guess that the rotation ‘maxes out’ at (0, 1, 0, 0), which represents a 180-degree rotation about the y axis, or at (0, -1, 0, 0), which also represents a 180-degree rotation about the y axis.

You could probably get the results you’re after by modifying Transform.eulerAngles or Transform.localEulerAngles. Or, you could use Transform.Rotate(), as previously suggested.