Any NPCs · Documentation
Events, Stimuli and Performance
Connect the crowd to your game: events when NPCs are hit, killed or call for help, gunshots and damage they react to, and the switches and settings that start, size and speed up the crowd.
← All Any NPCs documentation1 · Events
Hook NPCs into your game
The manager broadcasts three events. Each gives the NPC's actor (none for NPCs too far away to have one) and the other actor involved:
▾ AnyNpcManager > Events
To bind one in the Level Blueprint, select the manager in the level, right-click in the Level Blueprint and choose Create a Reference to AnyNpcManager, then drag from it and pick Bind Event to On Npc Killed (or the others).
2 · Stimuli and damage
Gunshots, explosions and fists
Two ways to make NPCs react to your gameplay:
- Report Stimulus on the manager, with a Make Ax Npc Stimulus node: a Kind (Crash, Violence, Loud Noise or Help Call), a Location, a Radius (default 20 m) and an optional Instigator. Every NPC in the radius draws a reaction from its type's weights for that kind; those that fight back go after the Instigator. Report a gunshot as Violence, a car horn as Loud Noise.
- Apply Damage, or any other Unreal damage, to an NPC's actor. The NPC loses health and dies at 0, the NPCs around it react to Violence, and unless the hit killed it, it reacts as Antagonized: it may flee, call for help or fight back.
Only nearby NPCs have a body. Damage needs an actor, and only the nearest NPCs have one. A stimulus reaches every NPC in its radius, with or without an actor.
3 · Control
Start, stop and size the crowd
By default the crowd starts when play begins. Turn off Start Automatically on the manager to start it yourself. The manager's Blueprint functions:
▾ AnyNpcManager
4 · Performance
A whole city of people
Every NPC is simulated as plain data; only the nearest get a character. Tune how many and how often:
▾ AnyNpcManager > Actors
Decisions such as crossing checks, following and reactions run ten times a second, while movement runs every frame. Characters are pooled and reused, their meshes only animate when they are rendered, and each road network's walking lines are built once when it loads.
5 · Multiplayer
Each machine runs its own crowd
NPCs aren't replicated. Each machine simulates its own crowd around its local players, so two players don't see the same pedestrians. A listen server simulates around its host only, and a dedicated server runs no NPCs.
That's everything. Have a game in mind that needs more? Send us a message or an image of the street life you want, and we'll help you build it with Any NPCs.