- Home /
 
               Question by 
               Epic0007224 · Sep 30, 2017 at 08:34 AM · 
                c#collisionontriggerenterontriggerexitontrigger  
              
 
              Problem with OnTriggerExit
I have an RTS style building game and I want to detect when the building I am placing is overlapping with an already existing building. This works fine, but when I use OnTriggerExit to detect when it is no longer overlapping, if it was overlapping with two buildings before, I can place it inside of one. How do I fix this?
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "building")
     {
         collided = true;
     }
 }
 void OnTriggerExit()
 {
     collided = false;
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Epic0007224 · Sep 30, 2017 at 08:48 PM
I fixed it by changing OnTriggerEnter to OnTriggerStay.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                