|
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: 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.
(comments are locked)
|
|
Yeah that's right, about slowing down within 20. Here is a small [link text]unity project1 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).
(comments are locked)
|
|
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 The Inspector is nothing. Whatever bug effectively limits rotation, naturally "snaps back" Inspector changes also.
(comments are locked)
|

I'm not sure if I understand this correctly, but are you asking why your script limits are not enforced when the game isn't playing. If so, scripts are generally not executed in the editor. To execute them in the editor, you have to add a flag [ExecuteInEditMode] to the script. See http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html
No pal. I have not set up any limits, but it limits the X rotation. I do not want any limits.