Before we can check that the player capsule is touching the ground, we need to add all the objects in our level to a custom layer mask. This will let us perform the actual collision calculation with the Capsule Collider component that's already attached to the player. Proceed as follows:
- Select any GameObject in the Hierarchy and click on Layer | Add Layer..., as illustrated in the following screenshot:
- Add a new layer called Ground by typing the name into the first available slot, as illustrated in the following screenshot:
- Select the Environment parent GameObject in the Hierarchy, click on the Layer dropdown, and select Ground. After you have selected the Ground option shown in the following screenshot, click Yes when a dialog appears, asking you if you want to change all child objects:
By default, layers 0 - 7 are taken up by the Unity engine...