"Ontriggerenter2d" function is executed even with "Is Trigger" disabled

Asked

Viewed 427 times

1

I have Gameobject "player" with a box with "Is Trigger" unchecked, IE, is not a Rigger.

inserir a descrição da imagem aqui

In the script associated with the player there is the "Ontriggerenter2d":

//...
void OnTriggerEnter2D (Collider2D o) {
    print(o.tag);
}

When the player collides with any object, it performs this function, although the Switch box is not a Rigger.

I have no more box Collider associated with the player and I have no child objects.

I’m using Unity version 5.2.2f1.

  • I can’t see the Image Philip has some child in this object that could be with the trigger-marked Collider?

  • @Frohlich has no children (the information was in the question), but according to Matthew’s answer below, I understood how Rigger works. Thank you for your time.

1 answer

2


The script linked to the object with Collider has to be with On Trigger on, your player does not need a Collider Ontrigger if the object that has this setting already has.

  • 1

    Already understood Matthew, the function "Ontrigger" in the script associated to the player will be invoked when the player collides with another object that contains a Collider of type "Trigger". I thought that the object itself had to have a Trigger that would perform the function in its own script and not another object.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.