Advertisement
logancberrypie

stanScript

Aug 6th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class colisionRemove : MonoBehaviour
  6. {
  7. private void Start()
  8. {
  9. Debug.Log("start method ran");
  10. StartCoroutine(waitMethod());
  11. }
  12.  
  13. private IEnumerator waitMethod()
  14. {
  15. Debug.Log("waiting");
  16. yield return new WaitForSeconds(10);
  17. removeMethod();
  18.  
  19. }
  20.  
  21. private void removeMethod()
  22. {
  23. Debug.Log("removing");
  24. Collider[] colliderArray = this.gameObject.GetComponentsInChildren<Collider>();
  25. if (colliderArray.Length == 0)
  26. {
  27. return;
  28. }
  29.  
  30. for (int i = 0; i < colliderArray.Length; i++)
  31. {
  32. Collider collider = colliderArray[i];
  33. if (collider != null)
  34. {
  35. collider.enabled = false;
  36. }
  37. }
  38. Debug.Log("done");
  39. this.enabled = false;
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement