How to play certain animation on a third or fourth collison ?

I want to set certain collision effects

I need a code that detects and takes action on orderly collisions so his 3rd damage doesn’t come at 1st collision it must be a set order of collision at sequence at time they occur
rite now if I connect the animations on collision any will play but how do I get the code to play animation 1 on 1st collision 2nd animation on 2nd collision 3rd on 3rd collision etc

how do I do this.?
I have the animatiuons ready I just need a code thatr will play the right animations on the right collisons “orderly”

This code snippet will help if I got your issue right…

private int collisionCount = 1;

void OnTriggerEnter(Collider other)
{
if(collisionCount == 1)
{
//Play first animation
}
else if(collisionCount == 2)
{
//Play second animation
}
else if(collisionCount == 3)
{
//Play third animation
}
}

void OnTriggerExit(Collider other)
{
if(collisionCount == 3)
{
 collisonCount = 1;
}
else
{
collisonCount += 1;
}
}

@sid4

oh so I don’t need to do this by adding more animator controller layers? I checked yesterday and I heard people say I would need to add more layers in the animator controller? so to add a layer with different desired collisions actions (damage etc)

your way is obviously easier if it works - and ill try it 2day

also its a 2d game so is it same code