How to count from 2nd collision

Hi, i want to kill my player if it touch floor after landing on it, but problem is, that it’s spawning on this floor, then jump, and then land, and after launching the game player is immediately killed. I’m using OnCollisionEnter, and I want to count to 2nd collision and then execute any action. How can I do this?

Hi @kubawich

Declare a counter somewhere and increase it in the OnCollisionEnter block when you collide with the desired object. Upon collision add +1 to the counter, and when it reaches 2 then perform the action.

It should look something like this:

int counter = 0;
void OnCollisionEnter(Collision col) {
    counter = counter + 1;
    if (counter == 2) {
        // Do your stuff
    }
}

Or you can just spawn the player outside of the collider.