Converted MouseLook from C# to Java problems

Hey, sorry to keep posting but :confused: problem and this one has struck me big time, it works perfect looking up and down but i cannot look left or right so that also stops diagonal :confused: i used this code unifycommunity.com and change it because they said we could in the notes but help this is my code thank you in advance to whoever fixes it

enum Axes {MouseXandY, MouseX, MouseY}
var Axis : Axes = Axes.MouseXandY;

var sensitivityX = 15.0;
var sensitivityY = 15.0;

var rotationX = 0.0;
var rotationY = 0.0;

function Update ()
{
    if (Axis == Axes.MouseXandY)
    {
        // Read the mouse input axis
        rotationX += Input.GetAxis("Mouse X") * sensitivityX;
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
    }
    else if (Axis == Axes.MouseX)
    {
        // Read the mouse input axis
        rotationX -= Input.GetAxis("Mouse X") * sensitivityX;
    }
    else if (Axis == Axes.MouseY)
    {
        // Read the mouse input axis
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
    }
}

please help it looks like it should work to me because they are both the same as y except has changed please help thank you

There’s one instruction missing - just the most important, the last one in Update:

        ...
        rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
    }
    // this instruction was missing:
    transform.localEulerAngles = Vector3(rotationY, rotationX, 0);
}

With this instruction, this MouseLook works perfectly in all modes. Try it and let me know if you still have problems.

hate to bust in here but you forgot to limit the rotation. (please note that this is reference to anyone else who may be looking for this later on

enum Axes {MouseXandY, MouseX, MouseY}
var Axis : Axes = Axes.MouseXandY;

var sensitivityX = 15.0;
var sensitivityY = 15.0;

var rotationX = 0.0;
var rotationY = 0.0;

var minimumY :float =  -60F;
var maximumY :float =  60F;

var minimumX :float =  -360F;
var maximumX :float =  360F;

function Update ()
{
    if (Axis == Axes.MouseXandY)
    {
        // Read the mouse input axis
        rotationX += Input.GetAxis("Mouse X") * -sensitivityX;
        rotationY += Input.GetAxis("Mouse Y") * -sensitivityY;
    }
    else if (Axis == Axes.MouseX)
    {
        // Read the mouse input axis
        rotationX -= Input.GetAxis("Mouse X") * -sensitivityX;
        //rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
    }
    else if (Axis == Axes.MouseY)
    {
        // Read the mouse input axis
        rotationY += Input.GetAxis("Mouse Y") * -sensitivityY;
        rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
    }
    transform.localEulerAngles = Vector3(rotationY, rotationX, 0);
}

I annotated the limit x because I had no need for it in my code