Hi guys, i was wondering if you could explain something to me. I just made a script called mouse x basically its my own mouse move script :). But i came across a code that got me thinking why it is there and if i remove why it stops my rotation on the script. the script is here:
public enum RotationAxis {MouseX = 1}
var RotationAxisX = RotationAxis.MouseX;
var sensitivityX : float = 400f;
public var minimumX : float = -360;
public var maximumX : float = 360;
public var rotationX : float = 0;
var OriginalRotation : Quaternion;
function start(){
OriginalRotation = transform.localRotation;
}
function Update () {
if(RotationAxisX == RotationAxis.MouseX){
rotationX += Input.GetAxis("Mouse X") * sensitivityX * Time.deltaTime;
rotationX = ClampAngle (rotationX, minimumX, maximumX);
OriginalRotation = XQuaternion = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation = OriginalRotation * XQuaternion;
}
}
function ClampAngle (angle, min , max ):float
{
if(angle < -360f){
angle += 360;
}
if(angle >360){
angle -= 360;
}
return Mathf.Clamp (angle,min, max);
}
basically its the "Function ClampAngle " line that contains the code i am talking about. the code of line is
return Mathf.Clamp (angle, min, max);
this is the line of code that i am talking about if i delete this line of code it makes the x rotation completely stop and why is that :)
secondly i was wondering if someone can tell me what an Quaternion is :) thank you very much in advance :)
MCHALO