SpawnWatcher.cs 870 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class SpawnWatcher : MonoBehaviour
  5. {
  6. public bool spawnIsFree;
  7. public List<string> consideredTags;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. this.spawnIsFree = true;
  12. }
  13. // Update is called once per frame
  14. void Update()
  15. {
  16. }
  17. private void OnTriggerEnter(Collider other)
  18. {
  19. if (this.consideredTags.Contains(other.tag))
  20. {
  21. //Debug.Log("Spawn isn´t free because " + other.tag);
  22. this.spawnIsFree = false;
  23. }
  24. }
  25. private void OnTriggerExit(Collider other)
  26. {
  27. if (this.consideredTags.Contains(other.tag))
  28. {
  29. //Debug.Log("Spawn is free again because " + other.tag);
  30. this.spawnIsFree = true;
  31. }
  32. }
  33. }