- Home /
Color changing animation
I have a 2D enemy sprite with two animations, EnemyIdle and EnemyWalk.
When he is hit, I want him to change his colour to red and back to white which can happen in any of the 2 animations.
Is there a way to achieve this with animations?
Answer by zotey · Feb 24, 2015 at 07:17 PM
Hey,
You can do this trough scripting but i think the best way to do it is to use mecanim. You can do this via mecanim and make a trigger. when your character is hit change the color. By switching the sprite to a red one in your case., or maybe you can make a animation where it changes the color of the material.
I usually experiment a bit to find a good way to it.
Zotey
I know how to do it by scripting but doing it with mecanic an triggering a transition to another state where it changegs the color freezes the idling or walking animation.
Since it is a simple animation (just changing the color) I though there could be a way to have both.
Answer by Earlybird · May 03, 2016 at 04:05 PM
You probably need to add a new layer to your animator state machine that way you can maintain the walk while changing the colour state on the second layer.