- Home /
 
               Question by 
               TheViolaVerse · Nov 13, 2020 at 01:25 PM · 
                c#scripting problemgameobjecttagphysics.overlapsphere  
              
 
              Physics.OverlapSphere, if statement, gameObject.tag
I need help making an if statement that uses a Physics.OverlapSphere to detect a gameObject with a tag so I can set that gameObject as a target.
I achieved this already using an OnTriggerEnter, however, it only detects objects when they enter, so if multiple objects spawn at once, it will ignore them.
 void OnTriggerEnter (Collider other)
 {
     if (other.gameObject.tag == "Food")
     {
        target = other.gameObject.transform;
        hasTarget = true;
     }
 }
Thanks in advance!
               Comment
              
 
               
              You can view the documentation for Physics.OverlapSphere().
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                