Hello, I have been a unity user for quite a while now and i’ve been working on a new FPS game and its working great, the only problem is, on one mission the player is sitting inside a helicopter but no matter what he can always do a 360* rotate and I write different numbers of limits and even watched a tutorial and done the EXACT same thing and the guy on the tutorial worked but not mine! I’m using the default unity Mouse Look script and my Y axis works fine, but the X axis won’t listen to any of the numbers I write in, Sensitivity amounts are ok its just the “Maximum X and Minimum X”. Please help. Thankyou.
-Kickasskane Productions
This is because X limit wasn’t implemented (why ? God knows …) Here is one I modified few days ago :
void Update ()
{
if (axes == RotationAxes.MouseXAndY)
{
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0);
}
else if (axes == RotationAxes.MouseX)
{
rotationX += Input.GetAxis("Mouse X") * sensitivityX;
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
transform.Rotate(0, rotationX, 0);
}
else
{
rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
transform.localEulerAngles = new Vector3(-rotationY, transform.localEulerAngles.y, 0);
}
}