Answer the question
In order to leave comments, you need to log in
Removing and adding to list?
Am I understanding correctly or does it work differently?
When entering, I try to add an object to my list, and when I exit, remove it from there
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Zombie")
{
zombieArray.Add(collider.gameObject);
}
}
void OnTriggerExit2D(Collider2D collider)
{
zombieArray.Remove(collider.gameObject);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question