Skip to main content
‹ Back to Tutorials
Intermediate Unity

Unity Playmaker - Simple Bot AI using Unity Navmesh Target

Sep 12, 2021
About this tutorial

In this Unity Playmaker - Simple Bob AI using Unity Navmesh tutorial, I'll take a look at setting up a simple AI bot. I'll use the Unity navmesh as pathing for the bot to move along. Then I'll set up a Playmaker FSM that will get the destination of the target (the end of the level) and then move t

Written Guide

This tutorial builds an AI bot that navigates a level from start to finish on its own, using Unity's NavMesh system plus a two-action Playmaker FSM. It's a fast way to sanity-check that a level is actually traversable — and duplicating the bot turns it into a crowd.

Step 1 — Mark the walkable geometry as static NavMesh baking only considers objects flagged as Navigation Static. Group everything the player can walk on under a single parent — here it's a game object called Ground Group — select the parent, and check Static. Unity asks whether to apply the change to children; choose Yes, change children. Organizing walkable surfaces under one parent before you start is what makes this a single click instead of a hunt through the hierarchy.

Step 2 — Bake the NavMesh Open Window, AI, Navigation. The panel has a range of settings worth exploring, but the one to change first is Agent Radius. Set it to 0.1 — a small radius lets agents fit through narrow gaps and follow tight paths that a default-sized agent would refuse. Then click Bake. A light blue overlay appears across the walkable surfaces showing the generated navigation mesh, along with jump links marking where agents can traverse gaps. If a region you expected to be walkable isn't blue, it either wasn't marked static or the agent radius is too large for it.

Step 3 — Set up a target Place a sphere at the end of the level to act as the destination. Turn its Mesh Renderer off so it doesn't appear in game — you still want the game object present and visible in the scene view as a marker, just not rendered during play.

Step 4 — Add a NavMesh Agent to the bot Select the bot and add a NavMesh Agent component. This is what actually does the pathfinding and movement. The component exposes speed, acceleration, angular speed, and stopping distance. Drop the speed to 3 so the bot moves at a pace you can watch and evaluate rather than sprinting past everything.

Step 5 — Build the FSM Add an FSM to the bot and name it Bot Mover. It needs exactly two actions. First, Get Position: drag the target sphere into the game object field and store the result in a new Vector3 variable named Bot Target. Second, Set Agent Destination: set the game object to Owner (the bot itself) and pass Bot Target as the destination. That's the whole behavior — find out where the goal is, tell the agent to go there, and let the NavMesh system handle the route.

Step 6 — Watch it run Parent the camera to the bot so you can follow it through the level. Press play and the agent moves through the space, rotating to face its direction of travel and using the baked jump links to cross gaps. Any place it stalls or refuses to go is a genuine problem with the level's navigability, which is exactly what makes this useful as a testing tool.

Step 7 — Multiply the bots Create an empty game object called Bots and drag the bot inside it, then duplicate it repeatedly. Every copy carries its own NavMesh Agent and FSM, so each one independently finds its way to the target. With a dozen or more running you can see how agents avoid each other, where they bunch up at chokepoints, and whether your level has bottlenecks — information a single bot can't give you. Reattach the camera to one of them and press play to ride along through the crowd.

Unity tools by Bliz Studio
Built for our own games — now on the Asset Store

Multi Tag — unlimited hierarchical tags for any GameObject. Hierarchy Pro — style your whole hierarchy with rules. Made by a Unity dev, for Unity devs.

Explore our Unity assets →