Animation¶
How Massive Swarm System animates agents, and how to pick the right approach for your target hardware.
Choosing an approach¶
| Approach | Best for | Cost |
|---|---|---|
| VAT (Vertex Animation Texture) | Mobile, 1000+ agents, GPU instancing | Very low |
Animator + SwarmAgentAnimation |
Richer character animation at lower counts | Medium–high (skinned mesh) |
| No animation component | Rigid-body enemies, simple shapes | Minimal |
VAT Animation¶
VAT bakes skeletal animation into a texture. At runtime the agent mesh samples the texture to reconstruct vertex positions — no skeleton, no SkinnedMeshRenderer, no per-bone CPU work.
VAT agents use SwarmVatAnimation (added to the prefab) and render through SwarmVatBatch or standard GPU instancing. The VAT baker window is at Tools → Massive Swarm System → VAT Baker.
When to use VAT: targeting mobile, or when skinned mesh cost is visible in the profiler at your target agent count.
When not to use VAT: when you need real-time bone manipulation, IK, or procedural animation that cannot be pre-baked.
VAT bake workflow¶
- Assign a source skinned mesh prefab and animation clips in the VAT baker window.
- Click Bake VAT Prefab. The baker generates a
.asset(VAT data), a.mat(VAT material), and a ready-to-use prefab. - Assign the generated prefab to the agent archetype.
- At runtime,
SwarmVatBatchhandles draw calls and material property writes.
VAT Baker field reference¶
Open the baker at Tools → Massive Swarm System → VAT Baker. The window has a Simple / Advanced toggle and a Single Prefab / Batch toggle at the top.
Simple mode walks you through four numbered sections and hides advanced overrides. Advanced exposes clip loop flags, sample rate, and the normal-bake toggle. Use Simple for everyday bakes; switch to Advanced only when you need to override the preset's defaults.
Single Prefab bakes one source at a time. Batch bakes a list of prefabs that share the same clips, preset, and output folder — each prefab writes its own named VAT asset.
Section 1 — Source Prefabs¶
| Field | What it does |
|---|---|
| Model Or Prefab | The prefab, model asset, or scene object that contains the source skinned renderer. Drag directly into the drop zone or use the object field. |
| Source Renderer | The SkinnedMeshRenderer to sample. Auto-assigned from the prefab; override it here when the prefab has multiple skinned renderers. |
| Avatar | Avatar used by the temporary sampling Animator. Required for humanoid clips when the source has no Animator with an Avatar of its own. |
Batch mode shows an additional Avatar field labeled Shared / Fallback Avatar. Prefabs in the batch that already carry their own Animator + Avatar use their own; the fallback only applies to prefabs without one (typically FBX models imported without a rig). Use Auto Fill to pick the first available avatar from the batch list.
Section 2 — Animation Clips¶
| Field | What it does |
|---|---|
| Idle | Looping idle animation. Required for the agent to stand still. |
| Walk | Looping locomotion clip at walk speed. |
| Run | Looping locomotion clip at run speed. |
| Attack (Optional) | Optional one-shot attack clip. When baked, SwarmVatAnimation.TryPlayAttack() plays it at runtime. Leave empty if the archetype has no attack animation. |
Use Auto Find Clips to scan the source asset, its Animator Controller, and the current selection for clips named like idle, walk, run, or attack.
In Advanced mode, a Loop toggle appears inline for each clip. Simple mode keeps all locomotion clips looping and the attack clip one-shot, matching the expected runtime behavior for most archetypes.
Attack clip loop flag
The attack clip defaults to non-looping (one-shot). Enable the loop toggle in Advanced mode only for channeled attacks — looping an attack clip with TryPlayAttack will cause the animation to repeat indefinitely until another clip interrupts it.
Advanced Bake Settings (Advanced mode only)¶
| Field | What it does |
|---|---|
| Sample Rate | Frames sampled per second for each clip. Range 1–60. Lower values reduce texture size; higher values preserve fast motion. For clips used as slower-playback fallbacks (walk/run), the baker automatically raises the effective sample rate proportionally to maintain visual quality. |
| Bake Normals | Bake animated normals into a second texture for lit shading. Doubles the texture memory cost. Disable this on mobile to reduce GPU bandwidth. |
In Simple mode these settings are driven by the selected Preset. Switch to Advanced only when you need to override them.
Section 3 — Output¶
| Field | What it does |
|---|---|
| Output Folder | Asset-relative folder where the .asset, .mat, and prefab are saved. Use Pick Folder to browse or Use Default to reset to the package default. |
| Create VAT Material | Create a material wired to the baked VAT asset using the package VAT shader. Disable only if you have a custom material pipeline. |
| Create Ready Prefab (Simple mode) | Also output a prefab pre-wired to the baked asset and material. Disable to get raw VAT assets for a custom pipeline. |
| Update Linked Material (rebake only) | Refresh the existing linked material in place so renderers keep their material reference rather than pointing at a new file. |
Section 4 — Ready to Bake (Simple mode)¶
This section shows an estimated texture memory cost based on the source mesh vertex count, sample rate, and total clip duration. A traffic-light indicator flags the budget tier: green for desktop-safe, amber for large-but-manageable, red for likely too heavy for mobile. Review the estimate before baking on mobile targets.
Click Bake VAT Prefab (or Bake VAT if prefab output is disabled) to run the bake. The baker writes the generated assets to the output folder and shows a report in the section below.
Bake presets¶
The Bake Preset dropdown (collapsed by default in Simple mode) selects from four built-in presets that set the sample rate and normal-bake flag together. Choose the preset that matches your target platform, then override individual settings in Advanced mode only if the preset is not quite right.
| Preset | Platform | Notes |
|---|---|---|
| Mobile Low | Low-end mobile | Shortest sampling, no normals — smallest texture footprint. |
| Mobile Standard | Mid-range mobile | Readable motion without the normal texture cost. |
| Standard | Desktop / high-end | Balanced default for most desktop builds. |
| High | Desktop showcase | Higher sample density when memory budget allows it. |
Quickstart — typical bake steps
- Select a preset that matches your target platform.
- Assign the source prefab (drag into the drop zone).
- Assign clips — use Auto Find Clips first.
- Confirm the memory estimate looks reasonable for your target.
- Click Bake VAT Prefab.
VAT Importance LOD¶
When Enable VAT Quality LOD is on in SwarmSettings, distant agents (Reduced and Cheap tier) use a cheaper shader path: frame interpolation is disabled and normal-texture sampling is skipped at Reduced tier, and at Cheap tier the agent snaps to the dominant clip. The visual difference is negligible at the distances those tiers cover.
Animator-Based Animation (SwarmAgentAnimation)¶
For agents that need Animator blend trees, transition logic, or per-parameter animation control, add SwarmAgentAnimation to the prefab. It writes speed float parameters to the Animator based on the agent's simulated velocity.
SwarmAgentAnimation is visibility-aware: it stops writing parameters when the agent's renderer is off screen and resumes after a brief grace period, reducing MaterialPropertyBlock write cost for off-screen agents.
Key fields:
| Field | What it does |
|---|---|
| Forward Speed Parameter Name | Animator float that receives forward/backward speed. Leave empty to disable. |
| Strafe Speed Parameter Name | Animator float that receives left/right speed. Leave empty to disable. |
| Use Planar Speed When Strafe Parameter Missing | When no strafe float is configured, writes total planar speed into Forward Speed so 1D blend trees still animate while agents sidestep. |
| Update Only When Visible | Skips parameter writes when the agent's renderer is off screen. |
| Visibility Grace Time | Keeps updating briefly after leaving the camera view to prevent pop at the screen edge. |
Culling mode: by default, SwarmAgentAnimation applies AnimatorCullingMode.CullCompletely to every spawned agent. This is the cheapest culling mode — the Animator stops evaluating entirely when off screen. Change Animator Culling Mode in the component if you need a different mode.
Importance LOD and animation refresh¶
When Importance LOD is active, SwarmVisualManager refreshes Animator and VAT playback parameters less often for Reduced and Cheap tier agents. The refresh interval is set by Reduced Animation Refresh and Cheap Animation Refresh in SwarmSettings. Higher values reduce MaterialPropertyBlock writes per frame at the cost of slightly coarser animation cadence on distant agents.
GPU Instanced Rendering¶
Enable Use Instanced Rendering on a SwarmAgentArchetype to render that archetype via Graphics.DrawMeshInstanced instead of one MeshRenderer per agent. This is considerably cheaper at high agent counts.
Requirements:
- The prefab must not use a
SkinnedMeshRenderer. If it does, instanced rendering is skipped automatically. - The material must support GPU instancing.
- Shadows require a shadow-casting pass in the shader; some instanced shaders omit it.
When to enable: any archetype with a non-skinned mesh and a high spawn count. Combine with VAT for the best throughput — baked VAT uses a static mesh that works with instanced rendering.
Mobile prefab checklist¶
Apply these before releasing on mobile
- Use VAT animation instead of
SkinnedMeshRenderer+Animator. - Enable Use Instanced Rendering on the archetype.
- Use a single material per agent (no multi-material mesh).
- Keep the mesh low-poly.
- Disable shadow casting on the agent renderer.
- Set Animator Culling Mode to
Cull Completelyif usingSwarmAgentAnimation.