Chapter 3. Overview of Collision Matrix

In this chapter, you will learn types of different colliders in Unity3D, which define the collision shape of objects in scene and their Collision Matrix.

You will learn in detail about the following topics:

  • Collision Matrix
  • Trigger Matrix
  • Layer-based Collision Matrix

By the end of this chapter, you will get knowledge about the matrix of colliders and their types. Using a matrix configuration of two colliding game objects, we will see how we can define different actions.

During the development with Unity3D, you will encounter with the following terms:

  • Collision Matrix: This represents a matrix that shows which collider type will show a collision
  • Trigger Matrix: This represents a matrix that shows which collider type will fire a trigger event
  • Layer-based Collision Matrix: This represents a matrix that shows layer-based collision

The following figure will show you the different types of matrices:

Overview of Collision Matrix

Let's take a look at them in detail.

Collision Matrix 3D

You will learn about Collision Matrix for 3D development; this matrix will define which collider type will show collision. We can define different actions by configuring two colliding game objects. The following table defines the collision status of two colliding game objects based on the attached components. To apply Physics, the game object must have Rigidbodies attached. Collision Matrix here represents a matrix that shows which collider type will show a collision.

On collision, the following events will be generated (for the description, please check the previous chapter):

  • OnCollsionEnter()
  • OnCollisionStay()
  • OnCollisionExit()

    Note

    Only the collider that possesses a Rigidbody will show reaction on collision.

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

Collision Matrix 3D

Let's see how we read the preceding table with a few examples:

  • A static collider will detect collision with a Rigidbody
  • A Rigidbody Collider will detect collision with static, Rigidbody, and Kinematic Rigidbody Colliders
  • A Kinematic Rigidbody will show reaction on collision with a Rigidbody
  • In other conditions, no collision will be detected
..................Content has been hidden....................

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