why Same update method only works on one object ?
I have A update method I copied from another gameobject . whe I run the scene the method only runs some lines IE:
  if (Input.GetMouseButtonDown(0))
         {
           
             AudioSource _audioSource = GetComponent<AudioSource>();
             var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             RaycastHit hitInfo;
             if (Physics.Raycast(ray, out hitInfo))
             {
                 Health health = hitInfo.collider.GetComponent<Health>();
                 var rig = hitInfo.collider.GetComponent<Rigidbody>();
                 if(rig != null)
                 {
                    // string nane = rig.gameObject.name;
                    // Debug.Log(nane);
                    
                    
                     rig.AddForceAtPosition(ray.direction * 3f, hitInfo.point, ForceMode.VelocityChange);
                     _audioSource.clip = _shootSound;
                     _audioSource.Play();
 
                       health.HealthPoints -= DamagePerHit;
 
                 }
             }
         }
 
               This method works perfect on my first object but the same method on the other object just runs until debug.log. It does't recognize the component Health even deactivating the first object. Could someone help me.
               Comment
              
 
               
              Your answer