Adding a custom layer

We will now add a custom layer to the obstacles object:

  1. To add a new layer, we will navigate to Edit | Project Settings | Tags:
  1. Assign the name Obstacles to User Layer 8.
  1. We then go back to our cube entity and set its layer property to Obstacles:
Creating a new layer
  1. When we use raycasting to detect obstacles, we check for those entities, but only on this particular layer. This way, the physics system can ignore objects hit by a ray that are not obstacles, such as bushes or vegetation:
Assigning our new layer ...

Get Unity Artificial Intelligence Programming - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.