Crowd Component
The Crowd component (plCrowdComponent, category Gameplay > Crowd) runs a crowd simulation and draws it. Put one on an object at the centre of your ground: the 2 x 2 km city is laid out on that object's XY plane, centred on its position and turned with its rotation.
The component does nothing until the scene simulates. When simulation starts it builds the city and the population from Seed and AgentCount, bakes the animation clips against the first near mesh, and creates a child object named CrowdShadows that draws the crowd into shadow maps. When the component is deactivated it deletes that object again.
Properties
Simulation
| Property | Default | Description |
|---|---|---|
AgentCount | 100000 | Number of agents, civilians and zombies together. Clamped to 100 to 400,000. Changing it while the scene runs has no effect until the simulation restarts (R, or Apply in the debug panel). |
Seed | 1 | Seed for the city layout, the population and every random decision. The same seed and count always play out the same way. |
RunScenario | On | Runs the scripted part of the scenario: two breaches 60 s after the start and the squad orders. Off leaves a city of civilians and roaming zombies with no breaches. |
BreachOnKey | Off | Breaches wait for the B key instead of firing at 60 s. |
Meshes, clips and materials
| Property | Default | Description |
|---|---|---|
NearMeshes | empty | Array of animated meshes, one per appearance variant. Each agent has a variant number from the seed; the mesh is variant mod count. The first entry also defines the skeleton and bone order that the animation is baked for. Required: without a valid first mesh nothing is drawn. |
FarMeshes | empty | Optional cheaper meshes for the far tier, in the same order as NearMeshes. An agent in the far tier whose variant has no far mesh uses its near mesh. |
Material | none | Optional material for every mesh. When empty, each mesh draws with its own first material. |
OutlineMaterial | none | Optional. Draws every agent a second time with this material, for an inverted-hull outline (a material using OutlineHull.plShader). See Outlines. |
IdleClip | none | Animation clip for civilians that stand. |
WalkClip | none | Clip for walking civilians. |
RunClip | none | Clip for running (fleeing) civilians. |
ZombieWalkClip | none | Clip for walking zombies. |
ZombieRunClip | none | Clip for running zombies (one zombie in six is a runner). |
DeathClip | none | Clip for dead agents. It plays once and holds its last frame. Without it the dead are not drawn at all. |
All meshes must be skinned to the same skeleton with the same bone order, which in practice means they are imported from the same skin. A missing clip plays the rest pose.
Drawing
| Property | Default | Description |
|---|---|---|
MaxVisible | 2000 | The most agents drawn per view: the nearest living agents in the view's frustum. Clamped to 0 to 20,000. |
NearCount | 100 | The nearest this many drawn agents form the near tier, with blended poses and the near meshes. The rest are the far tier. Clamped to 0 to 2,000. |
ShadowCount | 2000 | The nearest this many drawn agents of the main view cast shadows. 0 turns crowd shadows off. Clamped to 0 to 20,000. |
NearPoseRate | 0 Hz | 0 gives near agents a new pose every frame. A higher value holds each pose for 1/rate seconds, which looks like stop-motion. Up to 120 Hz. |
FarKeyRate | 0 Hz | 0 lets far agents show the nearest baked frame every frame. A value such as 12 to 15 Hz holds far poses at that rate. Up to 60 Hz. |
DrawDistance | 400 m | Agents farther than this from the camera are not drawn. Clamped to 10 to 5,000 m. |
DensityViewHeight | 150 m | When the camera is higher than this above the owner, the crowd is drawn as a coloured density map instead of characters. 0 turns the density view off. See City view. |
YawOffset | 0° | Turns every mesh about the up axis so it faces the way it moves. Use it when the imported character does not face the engine's forward axis. |
Debugging
| Property | Default | Description |
|---|---|---|
DrawCity | On | Draws the building footprints as grey boxes (8 to 24 m tall) and the safe zones as flat outlines: green when open, orange when closed, red when overrun. |
ShowStats | On | Shows the stats line in the top left corner. |
DebugPanel | Off | Shows the debug panel and changes several global cvars when simulation starts. |
Keys
While the scene simulates, the Crowd component reads two keys directly, whatever input is bound to them elsewhere:
| Key | Action |
|---|---|
| B | Fires the next breach that has not fired yet, held or not. The log reports Crowd: breach at plaza N. |
| R | Restarts the simulation from the start, with the current AgentCount and Seed. |
Keep this in mind if your game also uses these keys.
Stats line
With ShowStats on, the top left corner of the game view shows:
Crowd: tick 1670 (9.05 ms) | civilians 80000 (safe 0) zombies 19400 dead 0 | LOD active 7783 aware 42643 dormant 48974 | drawn 12821
B: breach R: restart
| Value | Meaning |
|---|---|
tick N (x ms) | Number of simulation ticks so far, and how long the last tick took on its worker thread. A tick is due every 50 ms. |
civilians, safe, zombies, dead | Living civilians (including those in safe zones and those infected), civilians inside safe zones, zombies, dead agents. |
LOD active / aware / dormant | Agents in each simulation tier. |
drawn | Agents drawn in the main view last frame. |
Debug panel
DebugPanel opens a Crowd window (Dear ImGui, see ImGui) for tuning the crowd while it runs. It needs an engine build with ImGui support; without it the property has no visible effect.
| Section | Controls |
|---|---|
| Header | Frame rate, last tick time, the counts of the stats line. |
| Simulation | Breach (B), Restart (R), an Agents slider (1,000 to 200,000) with Apply to restart at that count. |
| Drawing | Draw distance, Max drawn, Near tier, Shadow casters, Near pose rate, Far pose rate, City view height (the properties of the same names), and Outline: Off, Screen space or Mesh hull (only when OutlineMaterial is set). With Screen space, Edges from, Outline width, Narrows past, Silhouette threshold, Crease threshold and Outline opacity edit the Rendering.Outline.* cvars. |
| Shadows | Depth bias and Normal bias, the virtual shadow map cvars Rendering.Shadows.VSMDepthBiasTexels and Rendering.Shadows.VSMNormalBiasTexels. |
| Debug | Agent markers (sets Crowd.DebugView), City footprints (DrawCity), Stats text (ShowStats), Profiler overlay (Profiler.Overlay). |
Slider changes apply to the running component only; they are not written back to the scene.
When simulation starts with DebugPanel on, the component also sets these cvars for the rest of the session: Profiler.Overlay on; the screen-space outline on (Rendering.Outline.Enabled) with edges from depth (Rendering.Outline.Source = 0), no narrowing with distance (Rendering.Outline.PerspectiveDistance = 0) and 1.5 px width, and the hull outline off; Rendering.Shadows.VSMDepthBiasTexels = 6 and Rendering.Shadows.VSMNormalBiasTexels = 4, which removes shadow acne on small characters at street distance. Turn the property off for a scene you ship.