๐ฌ AnimationController for Unity
November 21, 2025 ยท View on GitHub
A production-ready animation manager that makes Unity's Animator actually pleasant to work with.
โจ Features
- Queue-based animation chaining - Play animations in sequence with callbacks
- Layer locking - Prevent interruptions during critical animations
- Smart looping - Return to previous states after temporary animations
- Performance optimized - Cached hash lookups and coroutine management
- Bulletproof safety - Handles component lifecycle edge cases
๐ Quick Start
// Basic playback
_animCtrl.Play("Jump", fadeDuration: 0.2f);
// Queue with callback
_animCtrl.Queue("Attack", onComplete: () => Debug.Log("Attack finished!"));
// Lock layer during critical animation
_animCtrl.Play("PowerUp", lockLayer: true);
// Loop with return-to-previous
_animCtrl.Play("Run", loop: true);
_animCtrl.Queue("HitReact", returnToPrevious: true); // Returns to Run after
๐ API Reference
| Method | Description | Parameters |
|---|---|---|
Play() | Play animation immediately, interrupting current | stateName (exact string name from Animator), layer=0, fadeDuration=0.1f, loop=false, returnToPrevious=false, lockLayer=false, onComplete=null |
Queue() | Queue animation to play after current finishes | stateName (exact string name from Animator), layer=0, fadeDuration=0.1f, loop=false, returnToPrevious=false, lockLayer=false, onComplete=null |
InterruptLayer() | Stop layer and clear queue | layer, fadeOutDuration=0.2f, force=false |
IsLayerLocked() | Check if layer is locked | layer |
SetFloat/Bool/Int/Trigger() | Cached parameter setters | param, value |
IsAnyLayerPlaying() | Check if any layer is playing | layer |
IsLayerPlaying() | Check if layer is playing | layer |
๐ฆ Installation
- Add
AnimationController.csto your project - Attach to GameObject with
Animatorcomponent - Configure your Animator Controller states
- Important: Enable "Loop Time" checkbox on animation clips you want to loop
๐ง Requirements
- Unity 2020.3+
- Animator component
๐ License
Apache License 2.0
Made with โค๏ธ by Me and AI