NEW V4.1- AI Routines
Overview
The AI Routine System manages daily NPC behaviors dynamically based on the in-game time, synchronized with Unreal Engine’s Day Sequencer.
Each NPC owns an ACFAIRoutineComponent, which reads from a UACFAIRoutineDataAsset defining the full-day schedule composed of multiple time-based routine tasks.
Core Structure and Flow
1. Routine Data Asset – UACFAIRoutineDataAsset
Defines the daily schedule for a specific AI profile.
Each entry (FAIRoutineTask) includes:
Start Time (Hour / Minute)
One or more Task Templates (
UACFTaskinstances)Optional Contextual Animation Scene Assets for Enter/Loop and Exit transitions
Each entry is uniquely identified by a GUID, automatically generated during schedule initialization.
2. Routine Component – UACFAIRoutineComponent
This is the main runtime controller of the system. It:
Retrieves the current time from the Day Sequence Subsystem (
GetApparentTimeOfDay())Converts it to minutes to determine which routine slot is active
Automatically transitions between tasks when time changes:
Calls
StopAll()on current tasksCalls
StartByGuid()on the next entry
Each active slot spawns or references runtime UACFTask instances handling the actual logic:
Smart Object interaction
Contextual animation playback
Ability activation, etc.
The component exposes OnRoutineTaskEnded, allowing Blueprints (e.g. Smart Object routines) to react dynamically when a task finishes.
3. Task Base Class – UACFTask
Represents a single modular AI behavior unit.
Each task implements:
OnTaskStarted()– Called when the task beginsOnTaskEnded()– Called when it finishes
4. Day Sequencer Integration
The entire system is time-driven, synchronized with the Unreal Day Sequence system.
By reading from the UDaySequenceSubsystem, the routines stay consistent with the simulated world time, ensuring perfect synchronization between:
Environment lighting and time of day
NPC behavior patterns
Ambient logic and world progression
Example
Time | Action |
|---|---|
08:00 | NPC plays “SitAtDesk” contextual animation and loops idle |
12:00 | NPC plays “StandUp” animation and moves to the cafeteria Smart Object |
18:00 | NPC leaves work, plays “ExitOffice” contextual animation, and runs the “GoHome” task |