Performance: Animator controller for 2D
MEDIUM IMPACT
This affects the frame rendering speed and input responsiveness by controlling how animations update and blend in 2D games.
if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Run")) { animator.Play("Run"); }
animator.Play("Run"); animator.Play("Jump"); animator.Play("Idle"); // called every frame without conditions
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated Play calls every frame | N/A | N/A | High CPU for animation recalculations | [X] Bad |
| Conditional Play calls only on state change | N/A | N/A | Low CPU, smooth animation updates | [OK] Good |