Instead of using Mesh Collider, sometimes it is better to use combined primitive colliders. For this, we create a parent-child hierarchy of colliders. Let's see this in the following example.
Example – implementation of compound colliders
Here, we will see how we can implement a compound collider in the following scene:
Create a new scene.
As shown in the following screenshot, select the Capsule and Sphere game objects and create a character shape:
Inside theInspector panel, you will see Sphere Collider and Capsule Collider. Check the Is Trigger option for both to make it trigger a collider and fire trigger events.
In this section, we learned how we can use primitive colliders for a complex game object. We will learn more about animation and compound colliders in later chapters.