Territory & Patrols
Documentation Unreal Engine AI Territory Patrol
Give an enemy ground of its own: place posts, list them on the enemy, and set a leash so a chase ends where you say.
A guard who returns to its doorway, a patrol that walks a route, and an enemy that stops chasing you across the level.
Set it up
45 seconds- 1
Place the posts
Search the Place Actors panel for SEC Territory Post and drag one into the level for each spot. One post is a guard station. Two or more are a patrol route. - 2
List them on the enemy
Select the enemy in the level. On its SEC Territory component, add each post to Posts, in the order you want them walked.BP_Enemy▾TerritoryPosts0 Array elementsResting BehaviorPatrol PostsPosts sit on the placed pawn, so the route is edited next to the enemy that walks it. - 3
Set how far it may be dragged
Tick Leash Enabled and set Leash Radius in centimetres. Leave Leash Anchor on Self, which centres the ring on the spot you placed the enemy at.BP_Enemy▾Territory | LeashLeash EnabledLeash AnchorSelfLeash Radius2000A new component ships with the leash off, so an enemy chases without a boundary until you ask for one. - 4
Play, and watch it walk
Press Play and runSEC.Debug.Territory 1. Each enemy draws its leash ring, every post with its wander area, a line to the spot it is walking to, and a line of text saying what it is doing.
The SEC Territory component holds the route and answers questions about it. It walks nothing. Something else gives the order, and by default that is the built-in brain, which runs whenever the enemy's Enemy AI Config leaves State Tree empty. Point that config at a StateTree carrying no territory tasks and the posts sit unused with no warning.
What ground each post owns
Any actor works as a post. SEC Territory Post is the ready-made one. Drop a SEC Territory Post component on a statue, a brazier or a doorframe already in your level and that actor becomes one, tuned in its own Details panel. An actor carrying no post component still counts, and reads as a plain spot to stand on with no wait and no wander area.
Shape decides what ground the post owns:
| Shape | Ground it owns |
|---|---|
| Point | The post itself. A guard holding a doorway or a spot on a wall. |
| Radius | Reachable spots within Wander Radius (400 cm) of the post, which reads as loitering rather than standing to attention. |
| Box | Reachable spots inside Wander Box Extent (400, 400, 200 cm), turned with the post. For a corridor, a bridge or a ledge where a circle would spill over the edge. |
Details
SEC Territory Post
Post
Shape
Point
Pass Through
Snap To Ground
Track Owner Movement
Wander
How To Pick
Random
Wander Radius
400
Wander Box Extent
400.0, 400.0, 200.0
Arrival
Wait Time
3
Wait Time Variance
1
Arrival Radius Override
0
Advanced
Point Sample Attempts
12
How To Pick shows for the Radius and Box shapes, Wander Radius for Radius, Wander Box Extent for Box.
Wait Time (3 s) is how long the enemy stands there before moving on, and Wait Time Variance (1 s) spreads a pack out so it does not move in lockstep. Pass Through skips the wait entirely, which shapes a route around a corner without adding a pause.
Snap To Ground puts the post on walkable ground rather than the height you dropped it at: navmesh first, the floor underneath second, the placed spot when neither is there. Untick it where the exact placement is the point, such as a walkway the navmesh already covers.
The post component carries its own transform, so move it to put the standing spot somewhere other than the actor's pivot. That matters on a large mesh whose pivot sits in the middle of it.
A wander area needs navmesh under it. A post whose area offers nothing reachable stands the enemy on the post itself and logs once.
Which spot inside the area
How To Pick shows for the Radius and Box shapes and decides where inside the area the enemy heads.
| Value | Result |
|---|---|
| Random | A different spot each time, anywhere inside the area. The ordinary choice for an enemy loitering with nothing in particular to guard. |
| Nearest | The near edge, so an enemy arriving from the east settles on the east side instead of walking on to the middle. For a patch several enemies approach from different directions. |
| Farthest | The deepest part of the area away from the enemy, so it backs off rather than settles where it stands. For a spot an enemy falls back to. |
AdvancedA post that works its own spot out
Make a Blueprint child of the SEC Territory Post component and override Pick Point In Area for a post whose destination comes from your own rule: a seat that fills up, a spot that moves with the light, a lane that closes at night. It receives the pawn being sent there and returns the world location to walk to; returning false stands the enemy on the post instead.
The base version samples reachable spots inside the area and picks among them under How To Pick, which is what an override replaces.
The leash
Leash Enabled is off on a new component, so the enemy chases as far as whatever drives it will take it. Tick it and two fields do the work: Leash Anchor says where the ring is centred, Leash Radius (2000 cm) says how wide it is.
| Anchor | Centres on |
|---|---|
| Self | The spot the enemy was placed or spawned at. The ordinary choice, and the one that needs nothing else set up. |
| Posts Centered | The middle of its posts. For a patrol free to range anywhere around its route rather than around whichever post it stands on. |
| Posts Union | A circle of Leash Radius around each post, taken together. For a route that bends around a wall the enemy should not cut across. |
| Actor | The actor named under Leash Anchor Actor. Point it at a Box-shaped post, or at any volume, to hold a whole pack inside one arena whatever posts each of them patrols. |
Leash Break Grace Time (2 s) lets an enemy follow you a step past the line and carry on if you come back, rather than turning on the spot like a tripwire. Once the window runs out it gives up the fight and heads home.
Only Fight Inside Leash is on, which makes the enemy ignore a target standing beyond its ring and engage the moment one steps inside. It will not go and look at one either. Turn it off for an enemy that charges anything it notices and is dragged home by the leash instead.
Leash Radius is how far it chases. Wander Radius on a post is how far it drifts while idle. The leash is measured straight from its anchor, so setting it tighter than a post's wander area reads as broken while the enemy drifts to the far side of that area.
Disengage Behavior decides what a finished fight leaves behind, whether the target died or was lost:
| Value | Result |
|---|---|
| Return To Post | Walks back to the post the fight started at, however far away, and picks the round up from there. The choice for a guard who owns a place. |
| Settle Here | Takes the spot it is standing on as its ground. Its posts stay set but stop being its ground, so it neither walks back nor patrols until something re-points the route. For a roaming enemy that should settle where a fight left it. |
Details
SEC Territory
Territory
Posts
0 Array elements
Resting Behavior
Patrol Posts
Leash
Leash Enabled
Leash Anchor
Self
Leash Radius
2000
Leash Anchor Actor
None
Track Leash Anchor
Only Fight Inside Leash
Leash Break Grace Time
2
Disengage Behavior
Return To Post
Arrival
Arrival Radius
100
Route
Post Order
Sequential Loop
Patrol Start Delay
1
Patrol Start Variance
1
Advanced
Walk Retry Interval
1
Walk Retry Limit
3
Debug
Debug Overlay Territory
Posts live on this component alone; an empty list means the enemy owns no ground. The leash rows show once Leash Enabled is ticked.
What it does with nothing to fight
Resting Behavior on the territory component:
| Value | Result |
|---|---|
| Patrol Posts | Walks the posts in Post Order, waiting at each one as that post asks. The ordinary patrol, and what several posts are for. |
| Hold Ground | Stands at one spot and holds it: the post nearest to where it was placed, or the placed spot when it has no posts. It walks back there whenever something takes it off. |
Post Order decides which post comes next, and is ignored when there is only one:
| Value | Use |
|---|---|
| Sequential Loop | First to last, then back to the first. The ordinary patrol. |
| Sequential Ping Pong | First to last, then last to first. For a corridor where walking through a wall to reach post one would look wrong. |
| Random | A random post each time, never the one just left. For an enemy that should not be readable. |
Patrol Start Delay (1 s) and Patrol Start Variance (1 s) hold the enemy where it stands before a round begins. A row of guards placed together with the defaults will not set off on the same frame.
Debug it
SEC.Debug.Territory 1 // Posts, leash ring, route and a line of text per enemy
SEC.Debug.All 1 // Every SEC overlay at once
SEC.Debug.WatchPawn <name> // Narrow the overlays to one enemy
The text line reads
walking or standing, names the post the enemy counts as its current one, and gives the distance past or inside its leash edge. refusing target appears while it stands its ground rather than going after a target beyond that edge.Debug Overlay Territory on the component turns the same drawing on for one enemy, with no console. It survives a restart.
Select a post in the level and it draws its own arrival perimeter and wander area, plus the route of every enemy that lists it. A post nobody lists draws in a muted grey, which is how a post pointed at by nothing gives itself away.
AdvancedNothing is walking the route
In the order worth checking:
- Posts is empty. The enemy owns no ground and stands where you placed it. The overlay reads
post none. - The AI Config names a StateTree. The built-in brain runs only while State Tree on the Enemy AI Config is empty. A graph without the territory tasks holds the route and never walks it.
- No navmesh under the posts. The walk finds no route, waits Walk Retry Interval, tries again up to Walk Retry Limit times, then stands still and logs once.
- The post drew in grey when selected. No enemy lists it, so nothing walks there.
- Leash Enabled is off. Every other leash field then does nothing, including Only Fight Inside Leash, so the enemy chases without a boundary.
- Resting Behavior is Hold Ground. The enemy stands at one spot and holds it, which looks like a patrol refusing to start. Set it to Patrol Posts for a round of the route.
AdvancedArrival, and ground the enemy cannot reach
Arrival Radius (100 cm) on the component says how close counts as reached. A single post overrides it with Arrival Radius Override, for one in a crowded spot the enemy cannot stand exactly on.
A walk counts as arriving when navigation reports it reached the spot, or when the enemy stands inside the arrival radius anyway. A route that only reached part of the way satisfies neither and reads as a walk that found no route. The enemy then waits Walk Retry Interval (1 s) and tries again, up to Walk Retry Limit (3) times, before standing where it is and logging once.
Point Sample Attempts (12) on each post is how many spots it tries before giving up on one request. A selective How To Pick uses every try as a candidate and chooses among them, so raising it makes the choice finer; Random stops at the first spot it finds. Raise it for a long thin Box, where more tries land outside the box and get discarded.
AdvancedWhat it does on the walk home
Two settings describe the walk home rather than the ground, so they sit on the brain on the AI controller.
Details
SEC Brain
SEC|Brain
Territory
Leave Coordination While Disengaging
Block Actions While Disengaging
Territory category on the brain. What it does while walking home, as opposed to the ground itself, which the Territory component on the pawn describes.
Leave Coordination While Disengaging stops the enemy facing and remembering the target and drops it out of combat coordination, then rejoins on arrival, so its combat role is re-picked and may come back different. Leave it off to keep facing the target, which costs nothing and resumes the fight the moment it sees you again.
Block Actions While Disengaging stops the enemy attacking on the way home, so it does not swing at nothing. Turn it off for one that should keep throwing ranged attacks as it withdraws.
AdvancedPosts and anchors that move
Track Owner Movement on a post follows its actor instead of fixing the post where that actor stood the first time anything asked. Turn it on for a post carried by a cart or a lift. A tracked post with Snap To Ground on asks navigation where the ground is once per frame, so keep it for the few posts that genuinely move. Leave it off for scenery, and for an enemy that is its own post, so its ground stays where it spawned.
Track Leash Anchor does the same for a Self anchor: the ring travels with the enemy instead of holding the spot it started on. That is a leash that can never break, which suits an enemy meant to roam with a boundary that follows it.
AdvancedChanging the route and the leash at runtime
| Node | Does |
|---|---|
| Set Posts | Replaces the whole list. Nothing moves and no post is left current, so follow it with Set Route To Nearest Post or Set Route To Home Post. |
| Add Post | Appends one post, ignoring a null and one already listed. |
| Set Leash Enabled | Turns the leash on or off, leaving every other leash setting as it was. |
| Set Leash Radius | Changes how far the enemy may be dragged, in cm. |
| Leash To Actor | Centres the leash on an actor and switches the anchor to it, for an arena opened by a door, a cart the enemy guards, or a captain it follows. Turns the leash on. Passing None puts the anchor back on the spot the enemy holds. |
| Set Arrival Radius | Changes how close counts as reaching a post. |
| Set Post Order | Changes the visiting order, taking effect at the next post. |
| Set Ground Here | Makes the spot underfoot the new ground. The leash measures from there, the posts stay set without being its ground, and no walk is cancelled. |
All of them run on the server.
AdvancedReading it at runtime
The brain reports what it is doing through Get Brain Phase, which reads Idle, Resting, Investigate or Combat. Bind On Brain Phase Changed to drive an animation set from it. Alongside it sit Is Walking, Get Seconds Outside Leash, and Is Refusing Target, which separates two cases that look identical from outside: an enemy standing on its ground with nothing to fight, and one standing there ignoring a target beyond its leash. On Leash Broken fires once when a fight pulls the enemy past its leash, before it turns for home.
On the territory component itself:
| Node | Answers |
|---|---|
| Owns Ground | At least one reachable post, or a spot taken with Set Ground Here. |
| Has Leash | Whether this enemy has a leash to break at all. |
| Is Outside Leash | The pawn stands past the edge. |
| Is Target Outside Leash | A named target stands past the edge. |
| Get Distance Outside Leash | How far a spot lies past the edge, in cm, reading 0 at the edge and negative inside it. |
| Get Leash Anchor Location | Where the leash is measured from. |
| Get Ground Location | The one spot the enemy holds, which a walk home aims for. |
| Has Arrived At Ground | The pawn stands within the arrival radius of that spot. |
| Get Current Post, Get Home Post, Get Live Posts | The post in play, the one to walk home to, and the resolved list. |
| Get Wait Time Here, Is Current Post Pass Through | What the current post asks for on arrival. |
Find Territory Component takes a controller and hands back the component, checking the possessed pawn first, so a graph running on the controller reaches it without a cast. Find Post Component does the same for a post actor, and reads None for an actor carrying none. Get Post Location For and Get Wander Extent For answer for any actor, post component or not.
AlternativeDrive it from a StateTree
Point the Enemy AI Config at a StateTree and these nodes appear under AI | Territory. See StateTree Integration.
| Node | Does |
|---|---|
| Territory Patrol | Walks the route: one leg, the post's wait, then the next post. |
| Territory Investigate | Walks to a spot worth checking out and stands there. |
| Return To Territory | Walks the pawn back to its home post, or settles the ground where it stands. |
| Monitor Combat Leash | Latches a leash break once the grace window runs out while a combat state runs. |
| Hold Out Of Combat | Keeps the enemy out of coordination and off its actions for the duration. |
| Territory Owns Ground | Condition: the enemy has ground at all. |
| Pawn On Its Ground | Condition: the pawn stands on the spot it holds. |
| Pawn Outside Leash | Condition: the pawn has been dragged past its edge. |
| Target Outside Leash | Condition: the target stands past the edge. |
| Target Eligible For Combat | Condition: gate a target on the leash. |
| Resting Behavior Is | Condition: branch on Patrol Posts against Hold Ground. |
AlternativeDrive it from your own Blueprint
The component holds the route order, the wander sampling and the arrival maths, so a graph of your own never reimplements them. It decides two things: when to walk, and how long to wait.
- Event Possessed to cache the Territory and Movement Evaluator components.
- Set Route To Nearest Post.
- Delay for your opening pause.
- Pick Destination For Current Post, into Make SEC Return Options, into Begin Return To.
- Bind Event to On Return Complete, pointing at a custom event.
- On that event, Did Last Return Reach Destination on the Movement Evaluator, into Branch. True: Get Wait Time Here, Delay, Advance Route, back to step 4. False: Delay, then back to step 4 without advancing.
That is the whole loop, with no Event Tick and no variables of your own.
Pick Destination For Current Post hands out a fresh spot inside a wander area on every call, so ask it once per leg and keep the answer. To judge a leg, read the walk's own report; Has Arrived At and Has Arrived At Ground answer a different question, which is where the enemy is standing right now.
Integration
| System | Link |
|---|---|
| Awareness System | Decides what the enemy knows. Territory decides where it belongs. Together they give patrol, investigate and return. |
| StateTree Integration | The territory tasks and conditions, for a graph-authored brain. |
| Movement System | Walks the pawn to each spot. Target-relative movement stands aside while a walk runs. |
| Combat Roles | An enemy leaving coordination on the walk home rejoins on arrival and takes a fresh role. |
| API Reference | The lookups and the post override point in C++. |