|
Hi! I'm trying to make a 2d cannon game, but I've faced a problem. I should limit the x-rotation of that object between 10 and 80. Thank You!
(comments are locked)
|
|
This would depend on how you're rotating the object in the first place. If you're using physics and torque, a configurable joint would fit well. If you're rotating by manipulating the transform directly, without physics, it's probably best to maintain a variable containing the angle, and limit it yourself, perhaps using the Mathf.Clamp function. For example:
If you need a more detailed answer, please edit your question to include more detail about how you're rotating the object. transform.rotation is a quaternion...but you know that. :)
Oct 30 '10 at 03:56 PM
Eric5h5
oops, of course! bad example - fixing now
Oct 30 '10 at 06:40 PM
duck ♦♦
fixed. for all relevant disclaimers, please see my profile page ;-)
Oct 30 '10 at 06:48 PM
duck ♦♦
(comments are locked)
|
|
Have a look at the MouseLook script in Standard Assets, which has a rotation clamp function that would work perfectly in this situation as long as you're directly setting the rotation and not using physics. If you need a Javascript version of MouseLook.cs, it's here.
(comments are locked)
|

Does the object only rotate on the x axis?