- Home /
Unity Animator cant play the same animation twice.
Hello Everyone
Im using the Unity Animator component to move a simple tank around a grid like enviroment. I have animationsfor turining right, left, moving upwards, and rotating downwards 180 degrees and moving downwards.
When I play any of these animations they work once, but if I play the same animation once after another ( even after a brief period of time) the animation doesn't play. When I play a different animation and then play the first animation again it works. This doesn't make sense to me.
public void initiateTankMove()
{
if (mapReceiver.moveY == "Down")
{
animator.Play("Rotate180");
}
else if (mapReceiver.moveY == "Up")
{
animator.Play("MoveUp");
}
else if (mapReceiver.moveX == "Left" )
{
animator.Play("TurnLeft");
}
else if (mapReceiver.moveX == "Right")
{
Debug.Log("Intend to turn right");
animator.Play("TurnRight");
}
}
Please see below for inspector details for the Animator component. I have select 'Apply root motion' otherwise the tank starts at position 0,0,0 always, i randomly set the position of a tank at the beginning of a game.
I have also attached a screenshot of one of animation clip details
Im pretty sure that the code is being entered , as the log message for the 'Right' is played twice, however is doesn't look like the actual animation plays and performs the necessary transform.
Any help on this will be much appreciated.
Thanks
Answer by Grish_tad · Jan 07, 2018 at 10:34 AM
HI @kamal_p_99. In Animator window select transition (arrow between animation nodes) and uncheck "Has Exit Time".
Hi @Grish_tad
$$anonymous$$y Animator didn't have any transitions between each separate move. It was able to transition to a different move but not to the same move. I have added a transition from each clip to the waiting state now, as shown below and this seems have fixed the issue:
Thanks
Answer by yannvasseur · Sep 03, 2020 at 11:35 PM
I had the same issue, and same resolution.
I didn't have any link between animation and orange state. Linking it fixed it.
Tks for the help.,I had the same issue, and same resolution.
I didn't have any link between animation and orange state. Linking it fixed it.
Tks for the help.
Your answer
Follow this Question
Related Questions
Single Animation file for two different objects! HELP! 1 Answer
Addititive Animation Not Responding to Speed 1 Answer
Does character bones and rigs should be according to mecanim clip ? 0 Answers
Trouble with animation wrap mode-animation plays randomly 1 Answer
I Need The Help Or Advice Of A Unity Animation Expert 0 Answers