Trigger Matrix

Trigger Matrix here represents a matrix that shows which collider type will fire trigger events. On trigger, the following events will be generated (for the description, please check the previous chapter):

  • OnTiggerEnter()
  • OnTriggerStay()
  • OnTriggerExit()

    Note

    Only Trigger Collider will fire trigger events.

The following figure shows the table of the Trigger Matrix for 3D objects:

Trigger Matrix

Let's see how we can read the preceding table with the following examples:

  • The static collider will fire trigger events on collision with a Rigidbody Trigger Collider and Kinematic Rigidbody Collider
  • The Rigidbody Collider will fire trigger events on collision with a static Trigger Collider, Rigidbody Trigger Collider, and Kinematic Trigger Collider
  • The Kinematic Rigidbody Collider will fire trigger events on collision with a static Trigger Collider, Rigidbody Trigger Collider, and Kinematic Trigger Collider
  • The static Trigger Collider will fire trigger events on collision with a Rigidbody Collider, Kinematic Rigidbody Collider, Rigidbody Trigger and Kinematic Trigger Collider

Matrix for 2D Objects

Although in Unity3D, Physics for 2D objects and 3D objects are very similar, there are some differences in sending messages during collision.

There are some important differences that we will see in the following table. The matrix given in this table is based on the assumption that we are using 2D variants of colliders and Rigidbodies.

The table is based on instances where collision detection occurs and Collision2D messages are sent.

Matrix for 2D Objects

Let's see how we can read the preceding table with the following examples:

  • The static collider will fire collision events on collision with a Rigidbody only
  • The Rigidbody will show collision with a static collider, Rigidbody, and Kinematic Rigidbody Collider
  • The Kinematic Rigidbody will fire collision events with a Rigidbody

The following figure shows instances where Trigger2D messages are sent upon collision:

Matrix for 2D Objects

Let's see how we can read the preceding table with the following examples:

  • The static collider will fire trigger events on collision with a Rigidbody only
  • The Rigidbody will show collision with a static Trigger and Rigidbody Trigger
  • The Kinematic Rigidbody will fire collision events with a Rigidbody Trigger
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.40.189