Unity Playmaker - Third Person - Enemy AI - Enemy AI Manager
In this 3rd Person in Unity and Playmaker tutorial, I'll be showing how to set up the beginning of an Enemy AI Manager that will control the state of the enemy Spider. Then in the Manager, I'll show how to use the Roaming FSM and then also set up chasing the Player. FUN!! ► Download Playmaker at
This tutorial builds an Enemy AI Manager that decides what the spider should do moment to moment: roam quietly, or detect the player and chase. The Manager is a Playmaker FSM living on the spider that watches three boolean flags fed by the spider's other detection FSMs (player in range, field of view, and line of sight). When all three are true, the spider plays an alert animation and switches into a pursuit state. Because the spider is a prefab with no fixed reference to the player, the Manager finds the player at startup.
Initialize and find the player
With the spider selected, add a new Playmaker FSM named "Enemy Manager" and call its first state Init. Use a Find Game Object action to locate the object tagged Player and store it in a new variable called player. In the same FSM, declare three bool variables: player in range, line of sight, and field of view. Exposing these in the FSM lets the spider's other detection systems flip them on and off.
Let the detection FSMs drive the flags
Each detection FSM (Player In Range, Field Of View, Line Of Sight) has a "detecting" state and a "detected" state. In every detecting state, add a Set FSM Variable action that targets the Enemy Manager and sets the matching bool to unchecked. In every detected state, do the same but set the value to checked. Because all of these FSMs share the same owner, you can simply copy the action between states and repoint the variable each time, so the three booleans always mirror what the sensors currently see.
Roam until all three flags are true
After Init, transition into a roaming state. Drag the spider's Roaming Playmaker FSM component into the state and use Enable FSM to switch it on, unchecking "reset on exit" so it stays enabled only for that state. Then add a Bool All True action checking field of view, line of sight, and player in range, set to run every frame; when all are true it fires a "player detected" event. Color the roaming state blue, the next state orange (alert), and the chase state red so the graph is easy to read.
Alert, then chase the player
In the Alert state, disable the Roaming FSM, then use Set Animator Trigger to fire the "alert" trigger, which plays the spider's roughly one-second rear-up animation (set up from Any State with Has Exit Time). Add a Wait action of 1 second so the animation finishes before transitioning to Chase Player. In Chase Player, set the animator float idle walk run to 1 so the blend tree shows the run, raise the NavMesh Agent max speed from 1 to 4, and use Set Agent Destination (Game Object) pointed at the stored player variable so the spider tracks the player wherever it moves. Finally, select Overrides, Apply All to push these changes to every spider prefab instance.





