How do I restrict rotation angles? The rotation just keeps slipping through the limit and stopping forever. When I set 355 as a limit, it stops at 354.993 or something. Can something be done about it? Is the problem with Update frequency?
I am using this code:
I need this for synching cursor movement with camera rotation, obviously.
Not clear what this code is trying to do. It looks like you're trying to limit the camera rotation to +/- 5 degrees, which seems a bit small.
Personally, I'd insert a dummy GameObject which sits at the cameraFocus position, with the camera parented to that. Then you just set the dummy's transform.rotation.eulerAngles, rather than doing a RotateAround which will gradually accumulate floating point error. You can then easily clamp the Y rotation to exactly what you want.
answered Jan 02 '12 at 03:37 AM