Limiting the rotation of an object

 0 I'm using a Object (Cannon) that rotates only in 2 axis. And I'm trying to limit the rotation that this Cannon can do. My object start with all Rotation in 0. And I want the rotation is limited from 0 to -90 (270). => This object cant rotate to angles > (more than) 0, and < (less than) 270 (or -90) I mean: (angle < 0 && angle > 270) A little CODE: `````` transform.rotation = Quaternion.LookRotation(inputRotation); // inputRotation get the mouse position (x, z). Z get the value of Y. transform.eulerAngles = new Vector3(0, 0, -transform.eulerAngles.y + 0);//-transform.eulerAngles.y + 0); `````` And I found this code to limit the rotation, but when I put the mouse in a position that give a angle more than 0, the object back to the value -90. If the object stayed in the position 0 when angle were more than 0, and stayed in -90 (or 270) when the angle were less than 270 will fixed. The function to limit: ``````function LateUpdate() { transform.rotation.eulerAngles = new Vector3( transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, Mathf.Clamp(transform.rotation.eulerAngles.z, 270, 360) ); } `````` Thks for all! more ▼ asked Dec 17 '10 at 11:18 PM HIT 13 ● 2 ● 2 ● 6 SisterKy 2.4k ● 33 ● 41 ● 59 2 days and nothing...someone ? Dec 20 '10 at 11:03 PM HIT add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 I had a similar problem (see here) that was solved by using transform.localEulerAngles instead. more ▼ answered Mar 10 '11 at 11:20 PM fetimo 27 ● 1 ● 1 ● 4 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x2168
x1038
x134
x55

asked: Dec 17 '10 at 11:18 PM

Seen: 1126 times

Last Updated: Dec 17 '10 at 11:18 PM