Hi,
I have a character that changes from a man into a wolf. A button is pressed to change from either state to the other state. That works but for some reason the animation plays a few additional times.
So if the player starts off as “Man” and the change button is pressed, the player changes this way:
Man (initial state) → Wolf → Man → Wolf
if the player is a Wolf and the change button is pressed, the player changes this way:
Wolf → Man → Wolf → Man
In both cases, the end result is fine. The player has changed into the other state, but the change animation has played too many times.
I am using a trigger in the Animator window to change from Man to Wolf. I am using another trigger in Animator to change from Wolf to Man. My script has this reference to the triggers:
`if(Input.GetKey(KeyCode.Space) && wolfMode == false){
wolfMode = true;
GetComponent<Animator>().SetTrigger("Man2Wolf_Trigger");}
if(Input.GetKey(KeyCode.Space) && wolfMode == true){
wolfMode = false;
GetComponent<Animator>().SetTrigger("Wolf2Man_Trigger");}
The odd thing is that all of this partially works. I don’t know why the animation loops a few times before ending up where I want it to be. If you look at the Animator graph, pressing the change bar triggers 1.5 cycles every time. I’ve played with the Animator transition settings with no luck and I’ve read some of the other animator threads too.
Thanks for your help!