# 7. Animation Pitfalls
Part of [[Animation]]. Prev: [[6.Worked Example Locomotion Look-At and Hand IK]].
## 7.1 Write Defaults
**Write Defaults** on a state (Inspector checkbox) makes the Animator write *default* values for properties not animated in that state's motion when the state is active. With modern layered setups this often causes:
- Fingers / face / prop bones popping when a locomotion state does not key them.
- Upper-body layer "losing" pose between gestures.
**Practical rule for Unity 6 work:** turn **Write Defaults OFF** on new controllers unless you know you need the old behavior. If you inherit an old asset with WD on, fix missing curves instead of relying on defaults. (Behavior nuances across layers → Animation advanced.)
## 7.2 Transition interruptions and Cancel spam
- **Any State → Hit** without a gate can retrigger forever while `Hit` stays true — use **Trigger** (auto-consumed) or reset a bool on enter.
- Attack recovery with **Interruption Source = None** prevents flinch from canceling the end of a punch when you do not want it; wind-up may use **Current State** so a flinch *can* cancel. See Manual — Animation transitions / interruption.
- Exit Time + long **Transition Duration** feels sluggish; too short pops.
## 7.3 Humanoid retargeting pain
- Bad Avatar Configure (wrong jaw, twisted wrists) retargets every clip poorly — fix the Avatar once.
- Mixing Generic clips on a Humanoid Animator (or the reverse) yields missing motion or import warnings.
- Scale mismatches between characters change stride length → foot slide when using root motion across cast members.
- Muscle limits too tight clamp aim poses; too loose → broken elbows.
## 7.4 Foot slide checklist
1. In-place clips but movement speed ≠ authored gait cadence.
2. Root-motion clips with Bake Into Pose accidentally left on XZ.
3. 1D thresholds not matching real m/s (`Compute Thresholds` helps — part 3).
4. CharacterController pushing through geometry while root motion also applies (double move) — pick one authority.
5. Blend Tree crossing opposite foot phases without sync (advanced).
## 7.5 Root motion vs physics fights
- `Apply Root Motion` on while a Rigidbody / CharacterController also writes position → jitter. Use `OnAnimatorMove` as the single applicator (part 4) or turn root motion off.
- Animate Physics update mode when not actually syncing to FixedUpdate physics → input lag perception.
## 7.6 Animation Events gotchas
- Function name typo → silent failure (no error if you do not watch).
- Event on a clip that is barely weighted in a blend tree → unreliable SFX.
- Overloads: Animator event binding is picky — one clear method signature with the matching parameter type (Float/Int/String/Object).
- Events fire on the Animator GameObject's components — putting the handler only on a child mesh often fails.
## 7.7 Layers and masks
- Forgetting the Avatar Mask on an upper-body layer → legs get overwritten by a reload anim.
- Additive layers without a correct reference pose → explode the skeleton.
- Layer weight left at 1 after a one-shot gesture → permanently overrides base locomotion arms.
## 7.8 IK fights
- `OnAnimatorIK` and Animation Rigging both targeting the same hand → last writer wins visually inconsistently. Zero one path's weights.
- TwoBoneIK Hint behind the shoulder → inverted elbow.
- MultiAim Aim Axis wrong → head aims with an ear. Iterate axes while scrubbing.
- Rig child accidentally parented *under* a bone → recursive evaluation nightmares. Keep `Rig_Setup` sibling to skeleton root (package workflow).
- Forgetting RigBuilder layer assignment → constraints do nothing.
## 7.9 Performance ([[Meta Quest 2]] note)
- Always Animate on many off-screen NPCs hurts Quest — use culling modes thoughtfully.
- Deep blend trees + many MaxFX layers + Animation Rigging constraints on a crowd → profile. Prefer simpler impostors at distance.
- Animation Rigging jobs are efficient relative to naïve script bone slerps, but every constraint is still work — disable `Rig.weight` / RigBuilder layers when unused.
## 7.10 Brain vs Animator anti-pattern
Polling `AnimatorStateInfo` for gameplay logic (`if (IsName("Attack2")) DealDamage()`) couples design to clip names. Prefer Animation Events for hit frames, or code timers in [[Enemy AI State Machine]] / [[Architecture and Code Patterns]] that *set* Animator triggers. Presentation follows gameplay, not the other way around.
## 7.11 Docs to keep open
- Manual 6000.5: Animator Controller, Parameters, Transitions, Blend Trees, Avatar Mask, Root Motion, Animation Events, `OnAnimatorIK`.
- Package: Animation Rigging 6.6.x Rigging Workflow + TwoBoneIK + MultiAim.
- Related tutorials: [[Timeline Basics]], [[Enemy AI State Machine]], [[Organic Enemy Sensing]], [[Surface-Walking with an Omnidirectional Player Movement]], [[Car Controller]], [[Level Up! (Review)]].
## 7.12 Verified vs unverified
**Verified:** transition interruption property meanings; root motion bake concepts; Avatar Mask regions; OnAnimatorIK requirements; Rig hierarchy guidance from package workflow.
**Unverified:** exhaustive Write Defaults interaction matrix across all layer blend modes (treat "WD off" as a project convention to validate); Quest-specific frame budgets for N constraints (profile on device).