Agent
AI system that creates NPC entities by pairing an Agent brain with a Character body. Agents possess characters, drive them via NavMesh pathfinding, and execute configurable ActionSequence behavior loops.
Architecture
Data Flow
Key Concepts
Agent
NPC brain that possesses a Character and runs an AI behavior loop
AgentSpawner
Scene-placed spawner that creates agent-character pairs on the host
AgentAction
Abstract Action subclass with agent/character/navmesh context for AI behaviors
AgentNetwork
Network component synchronizing possession state across clients
AgentPath
Simple path defined by child transforms, used by pathfinding actions
Possession
Agents implement IPossessor to control characters, same system used by players
Agent Lifecycle
AgentSpawnerinstantiates theAgentprefab as a network object (host-only).CharacterSpawnercreates aCharacterbody.Agent.PossessCharacter()connects them — addsNavMeshAgent, starts AI loop.The
ActionSequenceruns continuously, executingAgentActioninstances in order.Each frame,
NavMeshAgentparameters are synced with the character's motor settings.
Quick Start
Scene Setup
Place a GameObject with both
AgentSpawnerandCharacterSpawnercomponents.Assign the
AgentPrefab(must haveAgent,AgentNetwork,Possessorcomponents).Configure
SpawnCountfor the number of NPCs to create at startup.Configure the
CharacterSpawner's factory and variant in the Inspector.
Classes
AI brain with NavMesh pathfinding and behavior loop
Scene-placed spawner for agent-character pairs
See Also
Character System — the character body that agents possess
ActionSystem — core action/sequence system used for AI behaviors
Trading — trade interactions between agents and players
Last updated