๐ŸŽฌ 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

MethodDescriptionParameters
Play()Play animation immediately, interrupting currentstateName (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 finishesstateName (exact string name from Animator), layer=0, fadeDuration=0.1f, loop=false, returnToPrevious=false, lockLayer=false, onComplete=null
InterruptLayer()Stop layer and clear queuelayer, fadeOutDuration=0.2f, force=false
IsLayerLocked()Check if layer is lockedlayer
SetFloat/Bool/Int/Trigger()Cached parameter settersparam, value
IsAnyLayerPlaying()Check if any layer is playinglayer
IsLayerPlaying()Check if layer is playinglayer

๐Ÿ“ฆ Installation

  1. Add AnimationController.cs to your project
  2. Attach to GameObject with Animator component
  3. Configure your Animator Controller states
  4. 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