- Home /
 
Help with My C Sharp Script ????
Hi all, i was wondering if someone could help me, basically is created a Mouse look script in unity using both C# and Jave script, both work fine and run perfectly. But i created a new project and made a new C# script and created a new mouse look script identical to the other. but this time my mouse move script is not even responding it wont me along the x axis at all. this is strange i was wondering if some one spot anything wrong with it cheers
here is my script:
 using UnityEngine; using System.Collections;
 
               public class FpsMouseLookC: MonoBehaviour {
 
                public enum RotationAxis {MouseX =1}
   public RotationAxis rotX = RotationAxis.MouseX;
       public float  SensitivityX = 15F;
       public float  MaximumX = 360F;
          public float MinimumX = -360F;
             float RotationX = 0f;
                 Quaternion OriginalRotatioin;
     void Start(){
     if(rigidbody)
         rigidbody.freezeRotation = true;
         OriginalRotatioin = transform.localRotation;
 }
 void Update () {
       if(rotX == RotationAxis.MouseX){
         RotationX += Input.GetAxis("Mouse X") * SensitivityX * Time.deltaTime;
         RotationX = ClampAngle (RotationX , MinimumX , MaximumX);
            Quaternion XQuaternion = Quaternion.AngleAxis(RotationX, Vector3.up);
                             transform.localRotation = OriginalRotatioin * XQuaternion;
     }
 }
 
                static float ClampAngle (float Angle, float Max, float Min){ 
 
                 if (Angle <-360F)
         Angle += 360F;
     if(Angle > 360F)
         Angle -= 360F;
     return Mathf.Clamp (Angle, Min , Max);
 }
 
               } 
 
              Answer by MC HALO · May 14, 2011 at 04:56 PM
I Solved the problem :) it was within the Following line:
 RotationX = ClampAngle (RotationX , MinimumX , MaximumX);
 
               
               i was clamping them in the wrong order. Here is my correct code:
    RotationX = ClampAngle (RotationX , MaximumX, MinimumX);
 
               
               that was my problem :)
Your answer