We are going to set up a scene that looks like the following screenshot:
Our sample test scene with obstacles
Let's follow a step-by-step procedure to do this:
- We will create a directional light, the start and end game objects, a few obstacle objects, a plane entity to be used as ground, and two empty game objects in which we put the GridManager and TestAStar scripts. After this step, our scene hierarchy should be like this:
The demo scene hierarchy
- We will create a bunch of cube entities and tag them as Obstacle. The GridManager will look for objects with this tag when it creates the grid world representation:
The Obstacle nodes seen in the inspector
- We then create a cube entity and tag it as Start:
The Start node seen in the inspector
- Then, we create another cube entity and tag it as End:
The End node seen in the inspector
- We will create...