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.