Checking if an animation has been played finish

I want to do a jump for my gameObject, however I have no idea how to make it exactly like what I had in mind. When the gameObject(TB) collides into another gameObject(Tile) that’s beside it, the TB will stop moving, the TB Jump animation will be played, when the Jump animation is played finish, the TB will “teleport” to the end position of the animation. However, I have no idea on how to check if the Jump animation has been played finish or not. The values of the end position of the animation is known. Can anyone kindly help me? Help would be much appreciated. Thanks!

// If TetrisBabyState is Jumping
else if ( currentState == TetrisBabyState.jumping )
{
	// Find "01_tb_n_body"
	if ( gameObject.transform.Find("01_tb_n_body") )
	{
		// Play "Jump" animation
		gameObject.transform.Find("01_tb_n_body").animation.Play("body_01_jump");
				
		//If Jump animation has been played finish
		//Stop Jump animation and call Jump();
		Jump();
	}
}

1 Answer

1

try using

bool isDone = false;

if(!animation.isPlaying){
    isDone = true;
}

Remember to vote best answer :)