# Mouse Look Limit

 0 I am using Mouse Look for a 3d title but it seems to be able to rotate 360 degrees instead of any limit i put on it. The camera is at 40 degrees, and I wan't 10 degrees of movement possible to each side. Putting the minumum at 30 and maximum at 50 doesn't work. Any help? more ▼ asked May 19 '11 at 06:43 AM Max 4 254 ● 60 ● 64 ● 71 SisterKy 2.4k ● 33 ● 41 ● 59 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 Use this script for clamping the angle. Works with any input values. ``````function ClampAngle (a : float, min : float, max : float) : float { while (max < min) max += 360.0; while (a > max) a -= 360.0; while (a < min) a += 360.0; if (a > max) { if (a - (max + min) * 0.5 < 180.0) return max; else return min; } else return a; } ``````It's not mine, I think I got it at UnifyCommunity. I also had problems when setting limits to MouseLook, but using this function for clamping the angle worked perfect. more ▼ answered May 20 '11 at 11:53 PM Edy 637 ● 2 ● 5 ● 17 What do I change to change the maximum and minimum angles? May 22 '11 at 02:09 AM Max 4 Call this function from your script for clamping the angles, for instance: camera.transform.rotation.y = ClampAngle(myAngle, 30, 50) would allow the angle to have 10 degrees of movement around 40. May 23 '11 at 09:52 AM Edy I still don't get this. In the code you provided, how do I change the maximum and minimum angles? May 23 '11 at 11:18 AM Max 4 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Topics:

x327
x133
x22

asked: May 19 '11 at 06:43 AM

Seen: 1135 times

Last Updated: Jul 16 '11 at 12:06 PM