OnTriggerEnter2D sometimes works and sometimes don't

Can anyone help me? I have this code

void OnTriggerEnter2D(Collider2D coll)
        {
        anim.SetBool ("subebaja", true);
        anim.rigidbody2D.gravityScale = 0f;
        }

Well, it worked but suddenly stops working, the issue is that when I put in the gameobject the layer “Default” it works, but when I put in the layer “player” it doesn’t work

I have too

void OnCollisionEnter2D(Collision2D coll)
        {
        if (coll.gameObject.tag == "espada")
            {
            espada = true;
            Destroy (coll.gameObject);
            fuegos.particleSystem.Play();
            anim.audio.Play ();
            }
        }

And it’s the same case, when I put in the gameobject the layer “Default” it works, but when I put in the layer “player” it doesn’t work

Thank you.

I found it, check this
In the PhysicsSettings2D, I had 2 layers disabled, that’s why when I put in “player” layer it didn’t work.

1892011--121808--respuesta.jpg

1 Like