Limit on x rotation axis in play mode

Hello,
I am trying to rotate an object toward a target. I have achieved this on the Y rotation axis and trying to do the same for the X rotation axis. This is the code for rotating toward a target angle:

		diffAngle = Mathf.DeltaAngle(currentAngle, targetAngle);
	turnDirection = Mathf.Clamp(diffAngle / 20.0f, -1.0f, 1.0f);

It starts fine, rotating towards the target, but the rotation is clamped. Starting from 0 degrees, the object cannot rotate any further than 270 or 90 degrees. I tried adjusting the values in the editor, though I cannot drag the value beyond these limits. I tried adding a new Cube object, which does the same, so I have not coded anything to create this limit. When I stop the game the limitation is removed and I can rotate to any value I want.

I’m not sure why and would appreciate help in solving this problem.

That’s a small code fragment. There’s probably something messed up in the code that actually does the turning (which we can’t see.) It looks like turnDirection is set up to go full-speed if past 20 degrees, then slow down within 20. Looks fine. You might make it a public so you can double-check it.

The Inspector is nothing. Whatever bug effectively limits rotation, naturally “snaps back” Inspector changes also.

Yeah that’s right, about slowing down within 20. Here is a small [link text]unity project[1] reproducing the problem. It looks like DeltaAngle() returns a negative value after the initial 90 degree rotation, I don’t understand, hopefully this example will say more.

The rectangle (Hunter) should rotate to face the sphere (Prey).