I have a crate that opens when you press ‘e’ and a loot window appears thats when i want to disable my FpsMouseLook then when im done picking my item and close the loot window i can turn the FpsMouseLook back on using the same button to turn it off ‘m’ I can turn it off but cant get the mouselook to turn back on. here what i got please help
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 RotationX : float = 0f;
var OriginalRotation : Quaternion;
var RotationY : float = 0f;
var minimumY : float = -25f;
var maximumY : float = 25f;
var sensitivityY : float = 400f;
function Update () {
//******************Here is where im trying to turn it on and off***********//
if(Input.GetButton ("Fire1") && GetComponent (FpsMouseLook))
Destroy (GetComponent (FpsMouseLook));
//*************************************************************************//
if(RotationAxisRotationXY == 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;
}
if(RotationAxisRotationXY == RotationAxis.MouseY){
RotationY -= Input.GetAxis ("Mouse Y") * sensitivityY * Time.deltaTime;
RotationY = ClampAngle (RotationY, minimumY, maximumY);
OriginalRotation = YQuaternion = Quaternion.AngleAxis (RotationY, Vector3.right);
transform.localRotation = OriginalRotation * YQuaternion;
}
}
static function ClampAngle (Angle, min, max): float {
if(Angle < -360){
Angle += 360;
}
if(Angle > 360){
Angle -= 360;
}
return Mathf.Clamp (Angle, min,max);
}