Quick Path AI
Alekhine Games' Quick Path is a $10 AI that you can pick up from the Unity Asset Store. Although the next two AIs have more features, this AI is added because of its blocky nature. This block approach creates a grid-based path and is used with many types of games, but this AI works especially well with the excitement in the voxel game genre; it is suited for cubed topography.
To start with, perform the following steps:
- Create a new 3D scene and import the Quick Path AI from the Asset Store.
- Next, set up some cubes, planes, or other objects as your terrain, and then place all of these game objects into an empty game object. Name this game object
Terrain
. - Next, on the Inspector panel, add a component, QuickPath | Grid. Immediately, you should see a series of blue lines that show up on the cubes. These indicate all the points where a character can move in the AI.
- Now, we need a character to move around the scene. Create a sphere, or any object, and name it
NPC
. - Then, we'll add a Component, QuickPath | AI | Follow Mouse Object.
- Now, when you run the scene, assuming it is lit up and has the camera pointing where you want it to, you'll see
NPC
onTerrain
. - Click somewhere on the
Terrain
object, and watch theNPC
object move to that point. - Although we might say that the pathfinding in this is clearly working, we should also add an obstacle to the scene: something that shouldn't be stepped on. To do this, add another cube somewhere. Go to the Inspector panel for the obstacle and tag it with Obstacle by selecting that tag from the drop-down, or if it is not an option select Add Tag... and add
Obstacle
to the tag list. - Next, in the
Terrain
game object, in the Grid component, expand Disallowed Tags, increase the size to 1 and enter Obstacle for the new element. - Next, click on the Bake button at the top of the Grid component. Now you will see that the grid markers skipped the cube as an option. If you want to test more, click somewhere else on the
Terrain
object and watch theNPC
object move to the clicked point avoiding the obstacle.
Now, we've seen how to set up pathfinding with Quick Path, so let's look at another way to set up pathfinding with React AI.