Time integration (PulseAITimeBridge)
The bridge PulseAITimeBridge gives agents a daily routine on the clock of Pulse Time: the smith works at the anvil in the morning, eats at the tavern at noon and sleeps at night, the guard becomes a night watch at 22:00. Enable it next to PulseAI and PulseTime. Routines run on the server; clients see what the agents do.
Daily routine
A daily routine is a data asset (AI Daily Routine, Add > Pulse > AI Time in the Content Browser) with a list of windows. Each window has
| Field | Description |
|---|---|
FromHour, ToHour | Start (included) and end (excluded), hours of the day (6.5 = 06:30). Before FromHour the window wraps over midnight (22 to 6); 0 to 24 is the whole day. |
Weekdays | Days of the week (0 = the first day of the calendar’s week); empty = every day. A window over midnight belongs to the day it opened: Friday 22 to 6 still runs on Saturday morning. |
Activity | A gameplay tag that names the activity, for StateTrees, other systems and debugging. |
Kind | What the agent does, see below. |
The first window that contains the time wins. Put special windows (market day) before general ones and a 0 to 24 window last as the default. A time outside every window has no activity.
| Kind | What the agent does | Fields |
|---|---|---|
| Smart Object | Finds a free smart object slot with a gameplay behavior whose activity tags contain one of SmartObjectTags, walks there and uses it (sit at the campfire, sleep in a bed) | SmartObjectTags, SearchRadius, bSearchAroundHome, Speed |
| Place | Walks to the closest actor with the actor tag PlaceTag and stays there; looks in the actor’s forward direction on arrival | PlaceTag, AcceptanceRadius, bFacePlaceDirection, Speed |
| Profile | Switches the agent to Profile for the window (night watch); the routine switches back when the window ends | Profile |
| Custom | Nothing on its own: the StateTree reads the activity tag and decides |
Validation reports windows that are empty (From = To), Place windows without a tag and Profile windows without a profile.
Giving agents a routine
Add the extension Daily Routine to the Extensions of a profile and pick the routine. When an agent with the profile starts, its pawn gets a Pulse AI Routine component (UPulseAIRoutineComponent) with the routine. The component stays on the pawn when the profile changes, so a Profile window can switch to a profile without the extension and back. You can also put the component on a pawn by hand and set its Routine.
The component looks at the clock once per RoutineUpdateInterval (one timer for all agents of a world, see Settings) and right away when the time is set, skipped or loaded. When the window changes it
- switches the profile in and out of Profile windows (
bApplyProfiles), - sends the AI event
Pulse.AI.Event.Routine.Changedto the agent (payloadFPulseAIRoutineEventPayload: routine, window, previous window, activity, kind), - broadcasts
OnWindowChanged(Blueprint) andOnWindowChangedNative.
Profile switches
The routine remembers the profile it switches back to: the profile with the extension, or for a component placed by hand the profile the agent had before the first switch. It only switches away from that profile and only back from the profile it set itself. A profile that somebody else set in between (a quest, a dialog) stays: the routine leaves it alone until the agent starts again with a profile that has the extension.
A switch restarts the agent (SetProfile with restart). With bApplyProfiles off, only the task Go To Activity switches; its StateTrees then need the task in both profiles to switch back.
StateTree nodes
| Category Pulse AI | Time, for StateTrees with the Pulse AI schema. |
| Node | Kind | What it does |
|---|---|---|
| Time Between | Condition | The clock is inside FromHour to ToHour (and on one of Weekdays); bInvert passes outside. False without a clock. Works without a routine. |
| Current Time Window | Evaluator | Outputs bInWindow, EntryIndex, Activity, Kind of the agent’s routine and Hours, Weekday of the clock, to bind in conditions and tasks. |
| Go To Activity | Task | Does the activity of the current window: Smart Object and Place as above, Profile makes sure the profile is set. |
Go To Activity succeeds when the window ends (so the state is selected again), when the smart object behavior ends, on arrival at a place with bSucceedOnArrival, and right away in Custom windows. It fails outside every window, without a free slot or place, and without a path. Its output Target is the place of a Place window.
A tree for a villager on top of the guard pattern:
Root
├─ Combat ...
├─ Search ...
└─ Idle on event Pulse.AI.Event.Routine.Changed → Root
├─ Activity Go To Activity on succeeded → Root, on failed → Wander
└─ Wander Wander
Agents look in the place’s direction through the focus of their controller. A pawn turns with it only when it follows the controller’s rotation (Character Movement: bUseControllerDesiredRotation without bOrientRotationToMovement).
Settings
Project Settings > Pulse > AI > Time:
| Setting | Default | Description |
|---|---|---|
RoutineUpdateInterval | 1 s | How often the routines of all agents look at the clock, in real seconds. Setting or skipping the time updates them at once. |
Debugging
PulseAIRoutineInfo(cheat, runs on the server) prints the time and every agent with a routine: routine, current window, profile and the profile it switches back to.- Each window change is a timeline event (source
PulseAITimeBridge, categoryRoutine). PulseTimeSet 22:00andPulseTimeSkip <hours>of Pulse Time move the clock.