Guest User

Untitled

a guest
Dec 10th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. //Has to go at the top of your file
  2. #pragma strict
  3. import System.Collections.Generic;
  4.  
  5. //The list of colliders currently inside the trigger
  6. var TriggerList : List.<Collider> = new List.<Collider>();
  7.  
  8. //called when something enters the trigger
  9. function OnTriggerEnter(other : Collider)
  10. {
  11. //if the object is not already in the list
  12. if(!TriggerList.Contains(other))
  13. {
  14. //add the object to the list
  15. TriggerList.Add(Other);
  16. }
  17. }
  18.  
  19. //called when something exits the trigger
  20. function OnTriggerExit(other : Collider)
  21. {
  22. //if the object is in the list
  23. if(TriggerList.Contains(other))
  24. {
  25. //remove it from the list
  26. TriggerList.Remove(Other);
  27. }
  28. }
Add Comment
Please, Sign In to add comment