OnColliderEnter2D() on 2 scripts attached to the same Object

Hi, this is my problem, i have 2 scripts attached to the same GameObject and both call OnColliderEnter2D(), how is the behavior in this case? is there an Inspector order of execution? Always run first the same script and i don´t know why.

The problem is that one call TakeDamage() and the other call NearCheckpoints(), the last one search for nears checkpoints and move the player if any checkpoint is triggered, but when isDead == true; i don´t want to call NearCheckpoints() and i put in the IF statement a reference of isDead, but nothing happened, unity always move first the player to the near checkpoint and then call TakeDamage() that call PlayerIsDead()

So, kind of shady but i think that the idea is there.

So, after many tries i figured out that there is a real Inspector order execution so, problem resolved.

1 Like