Question by 
               VeeralSuthar · Dec 07, 2020 at 08:32 PM · 
                rotationfps controllertransform.parent  
              
 
              transform.parent.localRotation not working (Object reference not set to an instane of an object)
,Hello I am working on an FPS shooter and I am following a tutorial, but i keep getting the object reference not set exception.
The error is coming at the transform.parent.localRotation, but I have no idea why it isn't working, because the tutorial I am following has the exact same code.
variables:
     [Header("Mouse Settings")]
 
     public float mouseSensitivity = 1;
     Vector2 currentRotation;
my function:
     void DetermineRotation()
     {
         Vector2 mouseAxis = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
 
         mouseAxis *= mouseSensitivity;
         currentRotation += mouseAxis;
 
         transform.root.localRotation = Quaternion.AngleAxis(currentRotation.x, Vector3.up);
         transform.parent.localRotation = Quaternion.AngleAxis(-currentRotation.y, Vector3.right);
 
 
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                