Hello !
I have a list that contains GameObject. This list is empty at it start. At each collision I add the gameObject collisionned into the list. This parts works pretty well.
What I want to add to this is : Everytime I add a new gameObject to my list, there is a timer attached to this, and when the timer is done the gameObject is removed from the list.
I can’t do a global timer because every gameObject has to been handle separatly.
There is the code I already have (about adding gameObject into list) :
if (!GM.collisionTab.Contains(collision.gameObject))
{
GM.collisionTab.Add(collision.gameObject);
GM.compteurCollision++;
}
and later on the code I use it to change material, but it doesn’t help the problem I have.
I have been thinking about doing an array/list of timers but i can’t update each timer at the same time and separatly.
Also, I’ve been thinking about using coroutine but again, i’m not sure it would solve the problem.
The last thing I’ve been thinking is doing a class that contains a gameObject and a timer, with a method that would update the timer, but since i’m pretty new in this i’m not really sure I could handle this myself.
Thank you for your help !