I’ve written a script in order to lower a life for every collision with a trigger but when the player enters to a trigger the lives bring down extremely fast.
The scrip that i`ve written is that:
var Vida = 3;
function OnTriggerEnter2D (collision : Collider2D)
{
if(collision.transform.name == ("Finish"))
{
Vida -= 1;
}
Which is the mistake?
PD: I also want to lower a life when colliding with an specific tag, not a name, but I don’t know what I have to write…
Hi, it lowering super fast because it’s executed every frame it’s touching.
There had been tens of similar cases, please try google searching before asking:
And to check tag, create a new tag in tags list first, and in code it’s something like this.