To make an NPC travel to a destination while avoiding obstacles, follow these steps:
- Create a new, empty Unity 3D project.
- Create a new 3D Terrain by going to Create | 3D Object | Terrain. With this new Terrain GameObject selected in the Hierarchy window, in the Inspector window's properties, set its scale to 30 x 20 and its position to (-15, 0, -10) so we have this GameObject centered at (0,0,0).
- Texture paint this terrain with the SandAlbedo texture.
- Create a 3D Capsule named Capsule-destination at (-12, 0, 8). This will be the target destination for our NPC self-navigating GameObject.
- Create a sphere named Sphere-arrow that is positioned at (2, 0.5, 2). Scale it to (1,1,1).
- Create a second sphere named Sphere-small. Scale it to (0.5, 0.5, 0.5).
- In the Hierarchy window, make Sphere-small a child of Sphere-arrow and position it at (0, 0, 0.5):
Figure 10.2 – Setting Sphere-small as a...