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 documentation

1 · 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

On Npc Knocked Down An NPC was knocked down, with the vehicle or pawn that hit it
On Npc Killed An NPC died, with its killer if known
On Npc Called For Help An NPC called for help, with who it calls about and where it is: for police, witnesses or wanted levels

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

Start Npcs / Stop Npcs Start the crowd, or pause it where it is
Shutdown Npcs Remove every NPC and its actor. Safe to call from an NPC event
Set Max Npcs Change the crowd size while playing, for a busy event or an empty district
Get Npc Count / Are Npcs Running How many NPCs are alive, and whether the crowd is running
Get Environment What the sources report this frame: precipitation, the hour and the shelters

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

Max Npc Actors Most NPCs shown as characters at once. Default 60
Actor Radius NPCs within this distance of the player may get a character. Default 70 m
Full Rate Distance Characters this close, or on screen, follow their NPC every frame. Default 30 m
Far Update Interval Frames between updates of the other characters. Default 3

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.