Spawning Systems
Enemy Masses provides two primary components for spawning crowds without writing any code: Start Spawner and Spawn Trigger. Both components are designed to be drag-and-drop solutions for level design.
Common Settings
Both components share a core set of spawn configuration options:
Crowd Controller: Reference to the scene's
EnemyMassesCrowdController.Enemy Crowd Index: The ID of the faction to spawn (0 = First faction in the Controller's list, 1 = Second, etc.).
Spawn Count: How many agents to spawn.
Spawn Formation: The shape of the spawn group (Circle, Box, Line, etc.).
Spawn Location: A Transform defining where the center of the crowd will appear. If left empty, it uses the component's own Transform.
Enemy Masses Start Spawner
The EnemyMassesStartSpawner is a utility component designed to populate your scene with enemy crowds as soon as the game begins. It provides a simple, visual way to place armies, guards, or ambient crowds without writing initialization code.

Overview
This component handles the instantiation of a specific crowd faction at a specific location when the scene loads (specifically in the Start() method). It also includes powerful editor visualization tools to let you see exactly how the formation will look before you press Play.
Key Features
Auto-Spawn: Spawns automatically on
Start().Formation Preview: Draws a gizmo showing the exact position of every single agent in the formation (up to 256 agents for preview performance).
Post-Spawn Logic: Can automatically command the spawned unit to move to a destination or attack a target immediately.
Manual Control: Can be triggered manually via script if you disable the "Spawn On Start" option.
Setup Guide
Create the Spawner Object:
Create an Empty GameObject in your scene.
Name it something descriptive, e.g.,
Spawner_CastleGuards.
Add the Component:
Add the
EnemyMassesStartSpawnercomponent.
Link the Controller:
Assign your scene's
EnemyMassesCrowdControllerto the Crowd Controller field.
Select the Faction:
Enemy Crowd Index: Enter the index of the faction you want to spawn (corresponding to the list in your Crowd Controller).
Visual Feedback: The Gizmo color will update to match the faction's color.
Configuration
Spawn Settings
Crowd Controller: The manager responsible for the actual spawning.
Enemy Crowd Index: The ID of the faction to spawn.
Spawn Count: The total number of agents to spawn.
Spawn Formation: The geometric shape of the unit.
Circle: Agents form a filled circle.
Box: Agents form a solid rectangle.
Line: Agents form a wide line (good for battle fronts).
Ring: Agents form a hollow ring.
Spawn Formation Spacing: Overrides the default spacing defined in the
EnemyCrowdasset. Set to0to use the asset's default.Spawn On Start:
True: Spawns automatically when the scene loads.False: Waits for a manual call toSpawnNow().
Spawn Once: If true, prevents the component from spawning a second time (useful if you are toggling the GameObject on/off).
Spawn Location
Spawn Location: A Transform defining the center point and rotation of the formation.
Use This Transform If No Location: If checked and Spawn Location is empty, uses the component's own Transform.
Post Spawn Behavior
Define what the crowd does immediately after appearing.
Auto Set Destination:
True: Agents will try to move to a specific point.Destination Override: The Transform to move to. If empty, they will try to move to their spawn point (useful for correcting formation drift).
Auto Attack Target:
True: Agents will immediately aggro onto a target.Attack Target: The specific Transform to attack. If empty, they defaults to the Player Target defined in the Crowd Controller.
Visual Gizmos
The EnemyMassesStartSpawner features advanced editor visualization to help with level design.
Formation Preview: Small dots represent individual agents, showing you the exact shape, size, and density of the crowd.
Note: The preview is capped at 256 agents to prevent editor lag. If you spawn 10,000 agents, the preview will only show the first 256 to give you an idea of the density.
Direction Arrow: A large arrow indicates the "Forward" direction of the formation (crucial for Box and Line formations).
Destination Line: If a Destination Override is set, a dotted line connects the spawn point to the destination, visualizing the path the crowd will take.
Scripting API
If you disable Spawn On Start, you can control the spawner programmatically:
Dynamic Configuration
You can also modify settings via script before spawning:
Enemy Masses Spawn Trigger
The EnemyMassesSpawnTrigger is a powerful component designed to create dynamic encounters, ambushes, and wave-based events without writing a single line of code. It handles the logic of detecting players or objects and spawning a specific crowd faction in response.

Overview
This component combines a Trigger Zone (Collider) with a Spawner. When a valid object enters the zone, the component instructs the EnemyMassesCrowdController to spawn a new group of enemies.
Key Features
Auto-Collider Management: Automatically creates and manages its own Box, Sphere, or Capsule collider.
Flexible Filtering: Trigger on Player, Tags, Layers, or specific combinations.
Visual Feedback: Color-coded gizmos in the Scene View match the faction color, showing exactly where the trigger is and where enemies will spawn.
Combat Integration: Can automatically command spawned enemies to attack the specific object that tripped the alarm.
Setup Guide
Create the Trigger Object:
Create an Empty GameObject in your scene (or use a primitive like a Cube if you want a visible marker, then disable its MeshRenderer).
Name it something descriptive, e.g.,
Trigger_Ambush_Orcs.
Add the Component:
Add the
EnemyMassesSpawnTriggercomponent.Note: You do not need to add a Collider manually. The component will add one for you based on the Trigger Shape setting.
Link the Controller:
Assign your scene's
EnemyMassesCrowdControllerto the Crowd Controller field.
Select the Faction:
Enemy Crowd Index: Enter the index of the faction you want to spawn.
Tip: The Gizmo color will update to match the faction's color defined in its
EnemyCrowdasset.
Configuration
Trigger Settings
Crowd Controller: The manager responsible for the actual spawning.
Enemy Crowd Index: The ID of the faction to spawn (0 = First faction, 1 = Second, etc.).
Spawn Count: How many agents to spawn.
Spawn Formation: The geometric arrangement of the spawned unit (Circle, Box, Line, etc.).
Spawn Location
Spawn Location: A Transform defining where the center of the crowd will appear.
Best Practice: Create a child GameObject, move it to where you want the enemies to appear, and assign it here. This separates the Trigger Zone (where the player walks) from the Spawn Point (where enemies appear).
Use This Transform If No Location: If checked and Spawn Location is empty, enemies spawn directly on top of the trigger object.
Trigger Filters
Control what activates the trigger.
Activation Type:
PlayerTarget: Triggers only when the specific Player Transform (defined in the Crowd Controller) enters. This is the most performant and common option.Tag: Triggers when any object with the Required Tag enters.Layer: Triggers when any object on the Required Layer enters.TagAndLayer: Must match both.TagOrLayer: Matches either.Any: Triggers on anything (use with caution).
Trigger Behavior
Trigger Shape:
Box: Creates a BoxCollider.Sphere: Creates a SphereCollider.Capsule: Creates a CapsuleCollider.Note: Changing this automatically updates the Collider component on the GameObject.
Trigger Once:
True: The trigger fires once and then disables itself.False: The trigger can fire repeatedly.
Trigger Cooldown: If Trigger Once is false, this sets the minimum time (in seconds) between spawns.
Post-Spawn Logic
Auto Set Destination: If true, enemies will move to the spawn location (useful if they spawn slightly offset).
Auto Attack Triggering Object:
If
True: The spawned crowd immediately targets the specific object that entered the trigger.Example: If a specific NPC walks into the trap, the enemies attack that NPC, not necessarily the Player.
Visual Gizmos
The component draws extensive debug information in the Scene View to help you design your level.
Trigger Zone: Drawn as a wireframe shape (Box/Sphere/Capsule).
Spawn Point: Drawn as a wire sphere with a directional arrow showing the formation's forward facing.
Connection Line: A dotted line connects the Trigger to the Spawn Point, helping you see the relationship between "Cause" and "Effect".
Color Coding: All gizmos are tinted with the Faction Color of the selected Enemy Crowd.
Red Gizmo = Spawns Red Faction.
Blue Gizmo = Spawns Blue Faction.
Scripting API
If you need to control the trigger from your own scripts:
Last updated