Answer the question
In order to leave comments, you need to log in
How to delete an object after the timer expires?
Good afternoon.
Objects are randomly created on the map (copies of the prefab).
They are looking for food.
If they don't find it after 5 seconds, they die.
If found, the countdown starts again.
Etc.
How I imagine it:
...
eaten = 0;
if (Прошло 5 сек и не нашли еду)
Destroy(GameObject); // Удаляем объект с карты
predator.Remove(gameObject); // Удаляем его из списка
else
eaten++;
...
...
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