t1k:unity:animation:core
| Field | Value |
|---|---|
| Module | animation |
| Version | 2.2.2 |
| Effort | high |
| Tools | — |
Keywords: animation, animator, clip, state machine, unity
How to invoke
Section titled “How to invoke”/t1k:unity:animation:coreUnity Animation System
Section titled “Unity Animation System”Core Systems
Section titled “Core Systems”| System | Use When |
|---|---|
| Mecanim | Character locomotion, state machines, blend trees |
| Playable API | Runtime blending without AnimatorController, procedural animation |
| Timeline | Cinematic sequences, choreographed events, cutscenes |
| Animation Rigging | IK (arm/leg), head tracking, weapon aiming (post-bake pose) |
Animator — Quick API Reference
Section titled “Animator — Quick API Reference”Animator anim = GetComponent<Animator>();
// Parametersanim.SetBool("grounded", true);anim.SetFloat("moveSpeed", 3.5f, dampTime: 0.1f, deltaTime: Time.deltaTime);anim.SetTrigger("attack"); // call once per input event only
// Direct play (bypass FSM)anim.CrossFade("RunState", duration: 0.2f);anim.Play("IdleState", layer: 0, normalizedTime: 0f);
// Querybool inRun = anim.GetCurrentAnimatorStateInfo(0).shortNameHash == Animator.StringToHash("Run");float progress = anim.GetCurrentAnimatorStateInfo(0).normalizedTime;
// Layer blendinganim.SetLayerWeight(1, 0.5f); // upper-body overlay at 50%→ See references/mecanim-guide.md for BlendTree types, root motion, AnimationEvents, StateMachineBehaviour, Animation Rigging IK, performance tips, and gotchas.
Playable API — Quick Setup
Section titled “Playable API — Quick Setup”PlayableGraph graph = PlayableGraph.Create();var mixer = AnimationMixerPlayable.Create(graph, 2);graph.Connect(AnimationClipPlayable.Create(graph, clipWalk), 0, mixer, 0);graph.Connect(AnimationClipPlayable.Create(graph, clipRun), 0, mixer, 1);AnimationPlayableOutput.Create(graph, "Anim", animator).SetSourcePlayable(mixer);graph.Play();mixer.SetInputWeight(0, 0.7f);mixer.SetInputWeight(1, 0.3f);// CRITICAL: graph.Destroy() in OnDisable/OnDestroy→ See references/playable-timeline-guide.md for full graph patterns, custom PlayableBehaviour, Timeline setup, SignalTrack events, runtime binding, and gotchas.
Key Gotchas
Section titled “Key Gotchas”- Trigger auto-reset —
SetTrigger()resets after one frame; call once per input event - Hash parameters — use
Animator.StringToHash("name")for per-frame reads, not raw strings - graph.Destroy() mandatory — leaks GPU/CPU resources if skipped
- Root motion conflict — disable NavMesh/CharacterController when
applyRootMotion = true - Animator.Rebind() expensive — avoid at runtime; Instantiate prefab instead
- Timeline vs Animator conflict — playing both simultaneously causes flickering; pause Animator when Timeline takes over
File Organization
Section titled “File Organization”Assets/├── Animations/│ ├── Controllers/ # .controller assets│ ├── Clips/ # .anim assets│ ├── Rigging/ # RigBuilder, constraint prefabs│ └── Behaviors/ # StateMachineBehaviour scripts└── Timeline/ # .timeline assetsRelated Skills
Section titled “Related Skills”unity-cinemachine— Animation-driven cameras (Timeline)unity-vfx-graph— Animation-triggered VFXunity-input-system— Input-driven animation parametersdots-graphics— ECS rendering (usedots-implementeragent)
Reference Files
Section titled “Reference Files”| File | Contents |
|---|---|
references/mecanim-guide.md | BlendTree types, root motion, AnimationEvents, StateMachineBehaviour, IK Rigging, performance, gotchas |
references/playable-timeline-guide.md | Playable graph, custom PlayableBehaviour, Timeline tracks, SignalTrack, runtime binding, gotchas |