Unity Playmaker 3rd Person Enemy AI Detecting Player Range
In this 3rd Person in Unity and Playmaker tutorial, I'll be showing how the enemy AI can detect if the player is within range or out of range. This is the first part of multiple player detection tutorials (so stay tuned for Field of View and Line of Sight tutorials). ► Download Playmaker at https:
Before an enemy can chase, attack, or react, it has to know the player is nearby. This tutorial builds that foundation for a spider enemy: a trigger sphere defining its detection range and a two-state Playmaker FSM that flips between detected and not detected.
Step 1 — Add the detection sphere Select the spider and add a Sphere Collider component. The default radius is tiny, so increase it to define the actual detection range — 5 units works here, but this is the number you'll tune per enemy type. A patrolling guard might notice you from across a room; an ambush creature might only wake when you're right on top of it.
Step 2 — Make it a trigger Check Is Trigger on the collider. This is essential. Without it, the sphere becomes solid physics geometry and the player will bump into an invisible bubble five units from the spider. As a trigger it has no physical presence at all and exists purely to report overlaps.
Step 3 — Create a dedicated FSM Add a new Playmaker FSM to the spider and name it something descriptive — Detecting If Player In Range. On an enemy that will eventually have movement, attack, and health FSMs stacked on the same object, naming each one for its job is the difference between a readable setup and a mess.
Step 4 — Build the Detect Player state Name the first state Detect Player and add a Trigger Event action. Set the game object to Owner (the spider), and set the Collide Tag to player, matching the tag on your player object. Then choose the trigger type.
Step 5 — Use On Trigger Stay, not On Trigger Enter The Trigger Event action offers On Trigger Enter, On Trigger Stay, and On Trigger Exit. Enter seems like the obvious choice and it's the wrong one. Enter only fires at the moment of crossing the boundary — so if the spider spawns with the player already inside its sphere, or the player is standing there when the FSM starts, the crossing never happens and detection never triggers. On Trigger Stay fires continuously while the player is inside, which catches both the walk-in case and the already-inside case.
Step 6 — Fire the detection event Create a new event called Player Is Detected, assign it to the Trigger Event action, add the transition, and wire it to a new state named Player Detected.
Step 7 — Detect the player leaving The second state mirrors the first. Copy the Trigger Event action from Detect Player and paste it into Player Detected, keeping the same owner and player tag but changing the trigger type to On Trigger Exit. Create an event called Detect Player, add the transition, and point it back at the original state.
Step 8 — Test the loop Press play. The FSM sits in Detect Player waiting. Walk the player into range and it jumps to Player Detected. Walk back out and it returns to Detect Player. Watching the active state highlight move back and forth in the Playmaker window as you cross the boundary is the quickest way to confirm your range is set sensibly.
That's the whole detection layer. Everything an enemy does in response — chasing, attacking, alerting others — hangs off the Player Detected state, and each behavior can be added there without touching the detection logic again.





