I have attached an ObjectiveControl script to a gameObject (an objective). When player1colliders enter this objective, the onTriggerStay starts a timer. I would like to destroy this script if all player1colliders disappear from this objective (some may exit and some may be destroyed). I’ve put the following in onTriggerStay but is not working:
if (col.gameObject.tag != “Player1Collider”)
Destroy(this);
One thing I can suggest is putting all of the colliders that enter the objective into a list and removing them when they exit. Then check each object in the list for if they have the required tag. if an object does have the required tag don’t start the timer. If all of the objects don’t have the tag. Start the timer. Once the timer expires destroy the script.
The check can happen in update, though be sure to check if the list has nothing in it.