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