How to Trigger/collision only once time per gameobject hit's?
Soo first sorry for the English and second I'm making a AoE(Area of Effect) skill dmg in my game with collider/trigger but I have a problem when the Collider/trigger skill hit he can dmg multiple time the same enemy. but i want to only dmg once and once time each one!(if multiples enemy get hit) l tryed make a Bool array but don't work and i'm out of way what to do, becaus if I use only one boolean he will only triggers once the dmg and never triggers again. Like a explosion that grow and has 3s duration if a enemy is inside he will trigger every time the collider push the gameObject and I don't know a way to check what enemy are damaged.
Here is the code I tryed:
Bool[] alreadyHits;
...
private void OnTriggerEnter(Collider colisao)
{
y = enemies.Length; // from a enemys list
for(int x=0;x<=y;x++)
{
if (colisao.gameObject == enemies[x])
{
if (colisao.GetComponent<enemy01>() != null && !alreadyHits[x]) //becaus I have multiples script of enemys
{
print("get hit");
enemy01 ene01 = colisao.GetComponent<enemy01>();
ene01.getHit(dmg);
alreadyHits[x] = true;
}
}
}
}
but don't work at all. here is a example what I need:
A check list if already hit X enemy:
Enemy1 = alreadyHit? if no > do dmg, if yes > don't do dmg
Enemy2 = alreadyHit? if no > do dmg, if yes > don't do dmg
EnemyX = alreadyHit? if no > do dmg, if yes > don't do dmg etc
and is only in this instanciete skill if recast it i want to to one dmg again etc.
Now I have to figurate what to do I already try searching in multiples sites and in the forums but only find the one time trigger and is not I want anyone can help me?(and sorry if already exist here in the forum this thread)