Tactical AI
The tactical layer supplies cover points, destination queries, smart-object claims, and squad coordination. It builds on runtime navigation and integrates with AI Agents.
Configure generated cover
Open Project > Packages > Ai Project Settings > Tactical.
Select the navmesh used for cover generation, then tune probe heights and spacing for the characters in your game.
| Setting | Purpose |
|---|---|
Cover Navmesh | Navmesh from which cover is generated; empty selects the first configuration. |
Cover Point Spacing | Separation of points along suitable boundaries. |
Wall Probe Distance | Distance to search for blocking geometry behind a boundary. |
Crouch Cover Height | Probe height used to identify low cover. |
Stand Cover Height | Probe height used to identify high cover. |
Max Cover Points Per Sector | Cap on generated points per sector. |
Cover generation uses the chosen navmesh's physics collision layer. It follows sector generation and regeneration, so prebuild combat areas when queries need cover before anyone navigates there.
Enable AI.Tactical.VisualizeCover during simulation. Generated low cover is yellow, high cover is green, claimed points are red, and authored cover is distinguished in cyan. A claim reserves a position; the agent still needs to move to it.
Author cover points
AI Cover Point (plAiCoverPointComponent) supplies cover where automatic generation misses it, such as low sandbags that do not cut a navmesh boundary.
- Place it at a reachable position beside the obstacle.
- Point the owner's +X axis toward the wall.
- Set
QualityandHeight, or enableAutoProbeto measure protection and snap to ground at registration. - Leave
Width = 0for one point, or set a width to create a strip of claimable positions along the wall. - Simulate and inspect the registered points with the cover visualization.
The editor draws the authored extent before simulation. Registration still requires a configured cover navmesh. AutoProbe measurements override authored quality/height; they are not a continuous moving-cover scan.
Test tactical queries
AI Tactical Query Test (plAiTacticalQueryTestComponent) repeatedly runs a preset from its owner:
TakeCoverFromTarget: cover that hides the agent and faces the threat.HideFromTarget: hidden cover without requiring it to face the threat.FlankTarget: a side position with visibility.RetreatFromTarget: a position away from the threat.RandomNearSelf: a nearby navmesh position.
Set RadiusMin, RadiusMax, and QueryInterval. Give a threat object a global key and enter it in ThreatObjectKey for threat-relative tests. Enable ClaimBest on two test objects to inspect exclusion of claimed cover.
For custom generators, contexts, or scoring curves, use an AI EQS Query. A behavior can use Ai Pick Tactical Point or Ai Run Eqs Query, then Ai Navigate To. Keep the claim while traveling; release it with Ai Release Cover when leaving. Rebuilt sectors invalidate their old generated cover handles, so C++ consumers must not retain those handles indefinitely.
Smart objects
AI Smart Object (plAiSmartObjectComponent) marks a discoverable interaction point, such as a turret or idle location.
| Property | Purpose |
|---|---|
Type | Interaction category used by queries, for example Turret. |
Slots | Local positions and rotations where agents can interact. Empty means one slot at the owner. |
UseRange | How close an agent must be to use a slot. |
UseDuration | Fallback duration when game code does not handle use. |
UserEntries | Blackboard values applied to the using agent during the interaction. |
A typical state machine is Ai Pick Smart Object → Ai Navigate To → Ai Use Smart Object.
The picker writes Ai_SmartObjectPos and Ai_SmartObjectResult by default: 1 means found/claimed, 2 means unavailable. Navigate to the position before entering the use state. The use state reports 0 = using, 1 = done, 2 = failed in Ai_UseResult by default. Add failure paths for unavailable, out-of-range, or removed objects.
Use sends plMsgAiSmartObjectUse to the smart object's owner. A handler can start custom gameplay and call FinishUse(user) when done. Without a handler, the agent waits for UseDuration. The component does not automatically implement turret firing or interaction animation.
After use, UserEntries are reset to zero/default values rather than restored to their earlier contents. Reserve dedicated entries for these temporary controls. Use AI.SmartObjects.ShowDebug to inspect slots and claims.
Squads
Give cooperating AI Agents the same nonempty SquadId. Ai Project Settings > Squads configures:
- Attack Tokens: the number of members allowed an attack token.
- Share Confidence: the target confidence needed before sharing.
- Share Strength: the confidence passed to squadmates.
- Share Interval: minimum time between shares.
Squad inputs and blackboard information let behaviors respond to attack tokens and squad intent. Gate attack behavior on the squad token input; simply assigning a squad ID does not stop arbitrary game code from firing.
The squad module can publish coordinated advance/retreat information. State machines must consume it to produce movement or combat actions. Use AI.Squad.ShowDebug to inspect members, tokens, shared targets, and intent; AI.Squad.MuteSharing helps compare behavior with and without sharing.
