I have noticed that when my player dies by touching hazards he losses two lives instead of one.
Since this does not happen when he dies by touching an enemy, and since it doesn’t happen when I make sure to file in one hazard tile, I concluded this is because he is falling on two hazard tiles at the same time. (I’m using spikes so far, no water.)
I don’t know how to set it in code so that he loses only one live regardless of how many hazards he collides with. Please help.
I’m trying to understand what you mean. Are you placing to spike tiles together and the player falls in between them and this is what is causing the problem?
It’s a similar issue with the coins. Because there are two colliders that are being triggered, the body and the feet, this can result in multiple times being triggered. It must be the tiny amount of time that it takes to process the script that allows it to register twice before destroying it. I’ve added a check for the coins, I’ll look for a way to do it on the player also. Perhaps by setting the ProcessPlayerDeath() method to only happen if the player is alive. Something like this: