- Home /
How to swap a spriteRenderers source sprite at runtime when used by animator
I'm using an animator component on a gameObject with multiple children representing body parts of a character. Each child has a spriteRenderer component attached. The animator draws from the children's transforms and spriteRenderers for its animations.
I noticed that having the animator interact with the sprites prevents me from changing the spriteRenderer's source sprite from code at runtime.
The few solution I found utilize LateUpdate() to execute the sprite change after whatever black magic the animator is performing on it (often referring to Nordic Game Conference 2014 - 2D Development around minute 20). This works, but having to swap the sprite every update cycle seems like a very bad practice. Did someone since 2014 come up with a best practice to accomplish this kind of "hot swap" of sprites or is my fundamental approach wrong? Any insight would be great.
Your answer
![](https://koobas.hobune.stream/wayback/20220612233908im_/https://answers.unity.com/themes/thub/images/avi.jpg)