|
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. Please, help.
(comments are locked)
|
|
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. How do I add those eulerAngles then? What code would you use for that?
Jan 02 '12 at 09:43 AM
krides
Pretty much what you've got, except you want the rotation script to be on the dummy pivot object instead of the camera. Try this (may have typos, I write in C# usually): NB. You have to set the entire Vector3 - you can't modify transform.rotation.eulerAngles.y on it's own.
Jan 02 '12 at 05:05 PM
Winterblood
(comments are locked)
|
