Practical Use — Creating the Playable Terrain

Blue area(s) are navmeshed; the AI can path-find along those areas.

For a practical and simpler example of game AI and logical systems, I am going to reconstruct a “Duck Hunt” style game; the player will sit off the map with a firearm and attempt to pick off enemies who are navigating the map towards an exit.

The first step (once construction is done) is to create the navigable area for the enemies. In this case, I want them to go from the spawn door to the end door.

On the bottom left the spawn door is visible. The end door is on the top right.

Navmeshing this level is as simple as selecting the floor tiles and ramps I want the AI to use and baking them as walkable in the navigation window.

Selecting a section of flooring.

Once the desired terrain is selected, navigate to the navigation window (Window>AI>Navigation)

This will open a new window that looks like this.

Check and see which tab is selected; it may default to a different one!

We simply need to check “Navigation Static” and select “Walkable” from the “Navigation Area” dropdown menu on this screen (make sure you still have the desired floor selected in the editor window).

Finally, swap to the “Bake” tab at the top and on the bottom right press “Bake”

Repeat this process for the rest of the desired walkable area.

Next, the same process needs to be done for obstacles (railways, pillars, etc) but instead of “Wsalkable” selected from the drop down, “Not Walkable” must be selected. Without this step your AI will move through walls!

One of the pillars that need to be a solid barrier for the AI. Notice the grey unwalkable area around it.
Setting for the pillars.

With that, the terrain is set. Next up will be getting the AI to navigate from the start to the finish.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jack Leavey

Jack Leavey

34 Followers

I am a software engineer with years of experience branching into game development, specifically in Unity. Follow along for guides on creating game mechanics!