- Home /
Pseudo code: trigger portal system with coroutines
My apologies for this, I'm typing this on my phone. Assume this script is attached to a GameObject with a trigger collider. Is the logic behind this code correct? Imagine this code making objects visible whenever a player approaches and collides with the trigger, and deactivating them again when not. The reason why I'm using a list compared to TriggerEnter and Exit is because those two don't account for the warping of objects in and out of the trigger
 OnTriggerStay(Collider c):
 
 Colliders.add(c)
   If portalActive = False
      Start coroutine PortalUpdate
 
 PortalUpdate:
 
 portalActive=true
 InitPortal
 while colliders.count > 0
    colliders.clear
     yield
 end while 
 DeactivatePortal
 portalActive = false
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                