Script wont work when Debug log removed
So I feel like I'm having an odd problem. I made a script that will allow my object to move forwards after checking that it won't run into anything using Raycasts. I needed to debug so I put multiple debug.log(s) into my script. When I went to remove this particular debug.log (that still remains in the script below), the object no longer moves forwards. Any help is much appreciated!
     public float moveSpeed = 3f;                                       
     private BoxCollider boxCollider;                                        
     public float maxDistance = 3f;
 
     void Start()
     {
         boxCollider = GetComponent<BoxCollider>();            
     }
 
     void Update()
     {
         moveForwards();
     }
 
     void moveForwards()
     {
         boxCollider.enabled = false;                                              
         RaycastHit hit;
         Ray detectingRay = new Ray(transform.position, Vector3.forward);
         if (Physics.Raycast(detectingRay, out hit, maxDistance))
             Debug.Log("After if(Physics.Raycast(detectingRay, out hit, maxDistance))");
         {
             boxCollider.enabled = true;                                           
             if (hit.transform == null)                                            
             {
                 transform.Translate (Vector3.forward * Time.deltaTime, Space.Self);
             }
         }
     }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
My downloadHander.Text isnt working 0 Answers
How to log the GameObject from a Scriptable Object Event 0 Answers
Debug log not showing in iOS build 0 Answers
Keyboards Input not working 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                