Animation Clip Reuse

Identified a bug where AnimationClips were duplicated proportionally to the number of characters in town, using Memory Profiler. Debugged the root cause (FxClipEventRuntime).
Problem
When multiple instances of the same character appear in the town scene, AnimationClip memory was found to scale linearly with character count.
Measurements:
- 10 instances of the same character — AnimationClip 400MB (40MB × 10 per character)
- Expected — 40MB (when the clip is shared)
Repro: A Unity Memory Profiler snapshot showed 5+ concurrent 472.4 KB instances of the CH_MelonSoda_A001_Emotion_Happy_01 clip.
Issue Analysis
- 01
Issue Analysis
CookieIngameAnimatorController
└─ FxClipEventRuntime (clip-based EventFX)
└─ Instantiate(clipAsset) ← creates a copy after releasing the originalFxClipEventRuntimewas Instantiating the AnimationClip to handle event FX, then releasing the original. This was repeated for every character instance, so identical clip assets ended up resident in memory as independent copies — once per character.- Original clips were copied directly without an AnimatorOverrideController → broke the Addressables shared reference
- Memory grew linearly with the number of town users
- 02
Solution Approach
Character A ─┐
Character B ─┼─ Each with its own AnimatorOverrideController → references the shared AnimationClip asset
Character C ─┘
After aligning with the design/art teams: clip-based EventFX will not be used for in-game/town characters — feature is being removed.
Conclusion
Results
| Before | After | |
|---|---|---|
| AnimationClip for 10 of the same character | ~400 MB | ~40 MB |
| Cause | FxClipEventRuntime Instantiate accumulation | — |
Tradeoffs & Future Work
Tradeoffs
- Removing the clip-based EventFX feature itself — required confirming with the design team whether this feature is actually needed in-game
- Migrating to a shared AnimatorOverrideController structure requires re-reviewing the runtime clip swap logic