Skip to content

Targets

Add the SwarmTarget component to any GameObject you want the swarm to chase. It registers with SwarmManager automatically on OnEnable and unregisters on OnDisable.

Quick create

To drop a ready-made target into the scene, use GameObject → Massive Swarm System → Swarm Target (or right-click in the Hierarchy). This instantiates the Default Swarm Target Prefab set in Project Settings and guarantees a SwarmTarget component on it. For an existing player GameObject, add the component directly instead.

The bundled default target also includes a simple movement controller. In Play Mode, move it with WASD or the left stick on a connected gamepad. It works with Legacy Input, the Unity Input System, or both, so you can test a swarm before replacing it with your own player controller.

Body Radius

SwarmTarget owns the per-target body radius used by Approach And Surround (inner ring), Target Crowd Blocking, Target Body Blocking, and attack reach checks.

  • Body Radius SourceAuto Detect (default) or Manual. Auto Detect walks all non-trigger colliders on the GameObject and picks the largest planar radius among them. Supported types: SphereCollider (radius × planar scale), CapsuleCollider (radius × planar scale), BoxCollider (inscribed — the smaller of the X and Z half-extents), MeshCollider (bounds extents). A CharacterController on the same GameObject always takes priority over any collider. When Include Child Colliders is on (default), child colliders are also measured. Skinned mesh renderers do not contribute — add a Capsule or Box collider sized to the body.
  • Manual Body Radius — explicit value in world units used when source is Manual.
  • Detected Radius — read-only readout of the resolved value. A warning appears when Auto Detect found no collider source.

The body-radius gizmo (cyan wire sphere) draws on the selected target so you can see what the swarm will use.

Behavior

  • Any number of SwarmTarget objects can be registered at once. Agents only react to the closest Max Active Target Count of them at any moment — extras stay registered as fallbacks and become active automatically when they move closer to the swarm than a current active target. See Max Active Target Count on SwarmManager.
  • Agents use hysteresis when deciding to switch targets, so crossing movements between close targets do not cause thrashing.
  • Remove or disable a SwarmTarget component and agents reassign to remaining active targets automatically.
  • Velocity prediction is built in for moving targets — the per-target prediction blend is exposed on the manager's Target Selection knobs.

Adding the movement controller to your own target

The bundled default target prefab includes a DefaultTargetMoveController component for testing. If you want to add it to your own target GameObject:

  1. Select your target GameObject in the Hierarchy.
  2. In the Inspector, click Add Component.
  3. Navigate to Massive Swarm System → Input → Default Target Move Controller, or search for "Default Target Move Controller".

This is a getting-started helper. Replace it with your own player controller once the swarm is working. Real input controllers should implement IMoveInputSource rather than copying the DefaultTargetMoveController pattern.

Common patterns

Pattern How
Single player target One SwarmTarget on the player GameObject. Default behavior.
Multiple players (co-op) One SwarmTarget per player. Agents pick the closest by hysteresis.
Decoy / distraction Spawn a temporary GameObject with SwarmTarget. Disable it to release agents back to the player.
Boss + minions as targets One SwarmTarget per object the swarm should consider. Tune the manager's distance factor if certain targets should be preferred.