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

spinner

Data Flow

spinner

Key Concepts

Concept
Description

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

  1. AgentSpawner instantiates the Agent prefab as a network object (host-only).

  2. CharacterSpawner creates a Character body.

  3. Agent.PossessCharacter() connects them — adds NavMeshAgent, starts AI loop.

  4. The ActionSequence runs continuously, executing AgentAction instances in order.

  5. Each frame, NavMeshAgent parameters are synced with the character's motor settings.

Quick Start

Scene Setup

  1. Place a GameObject with both AgentSpawner and CharacterSpawner components.

  2. Assign the AgentPrefab (must have Agent, AgentNetwork, Possessor components).

  3. Configure SpawnCount for the number of NPCs to create at startup.

  4. Configure the CharacterSpawner's factory and variant in the Inspector.

Classes

Class
Description

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