x


Mouse Look Limit

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 gravatar image

Max 4
254 60 64 71

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 gravatar image

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
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Topics:

x327
x133
x22

asked: May 19 '11 at 06:43 AM

Seen: 1135 times

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