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.


108748-animator-srn.png


I have also attached a screenshot of one of animation clip details


108749-capture.png


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

HI @kamal_p_99. In Animator window select transition (arrow between animation nodes) and uncheck “Has Exit Time”.
alt text

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.