# What's wrong with this code

Hey guys, I was watching this tutorial on youtube for creating a mouselook script and the guy did give a link to another video he made because he said due to unity’s updates often it doesn’t recognise old code so then I watched the video where he was fixing all the problems, which I copied but they still end up giving me more errors after searching from old answers here on unity about the different errors. Anyone know what’s wrong with this, if so could you please help.

if (RotationAxisRotationXY == RotationAxis.MouseX){

var RotationX = Input.GetAxis(“Mouse X” * sensitivityX * Time.deltaTime) ; //fix//

RotationX = ClampAngle (RotationX, minimumX, maximumX);

OriginalRotation = XQuaternion = Quaternion.Angleaxis (RotationX , Vector3.up);

transform.localRotation = OriginalRotation * XQuaternion;

}
if(RotationAxisRotationXY == RotationAxis.MouseY

) RotationY -= Input.GetAxis (“MouseY”) * sensitivityY * Time.deltaTime;

RotationY = ClampAngle (RotationY, minimumY, maximumY);

OriginalRotation = Quaternion.AngleAxis;(RotationY, Vector3).right; }

transform.localRotation = OriginalRotation * YQuaternion;

static function ClampAngle (Angle: float , min: float , max: float): float {

if(Angle < -360) {
Angle += 360;

}
if(Angle > 360)

Angle -= 360;

return Mathf.Clamp (Angle, min, max);
}

Where is the complete code? (or link to the video)

This is the link where the guy is correcting the code.

Full code below:

public enum RotationAxis {MouseX = 0, MouseY = 1}

var RotationAxisRotationXY = RotationAxis.MouseX || RotationAxis.MouseY;

var sensitivityX : float = 400f;

var minimumX : float = -360f;

var maximumX : float = 360f;

var originalRotation : Quaternion;

var RotationY : float = 0f;

var minimumY : float = -25f;

var maximum : float = 25;

var sensitivityY : float = 400f;

var YQuaternion: Quaternion ;

var XQuaternion: Quaternion ;
function Update () {
}

if (RotationAxisRotationXY == RotationAxis.MouseX){

var RotationX = Input.GetAxis(“Mouse X” * sensitivityX * Time.deltaTime) ; //fix//

RotationX = ClampAngle (RotationX, minimumX, maximumX);

OriginalRotation = XQuaternion = Quaternion.Angleaxis (RotationX , Vector3.up);

transform.localRotation = OriginalRotation * XQuaternion;

}
if(RotationAxisRotationXY == RotationAxis.MouseY

) RotationY -= Input.GetAxis (“MouseY”) * sensitivityY * Time.deltaTime;

RotationY = ClampAngle (RotationY, minimumY, maximumY);

OriginalRotation = Quaternion.AngleAxis;(RotationY, Vector3).right; }

transform.localRotation = OriginalRotation * YQuaternion;

static function ClampAngle (Angle: float , min: float , max: float): float {

if(Angle < -360) {
Angle += 360;

}
if(Angle > 360)

Angle -= 360;

return Mathf.Clamp (Angle, min, max);
}

try using the code tags to make your code more readable in the forum (there is a sticky at the top of forum explaining how to)