I'm creating my first unity game for learning how it works. the game: a player needs to avoid monsters by jumping over them. if it collides with a monster, the player dies and a stone thumb animation appear in its place. My Player script has an Animator responsible for stand/walk animation like this
private Animator isWalkingAnimator;
isWalkingAnimator = GetComponent<Animator>(); //this is in Awake
void AnimatePlayer(string animatorName) //is called from Update
{
Vector2 scale = transform.localScale;
scale.x = playerWalkingState;
if(playerWalkingState != 0)//walk
{
isWalkingAnimator.SetBool(animatorName, true);
prevWalkingState = playerWalkingState;
}
else//stand
{
isWalkingAnimator.SetBool(animatorName, false);
scale.x = prevWalkingState;
}
transform.localScale = scale;
}
in private void OnCollisionEnter2D(Collision2D collision) If the user collides with an enemy
if (collision.gameObject.CompareTag("Enemy")) I wish isWalkingAnimator to show the thum stone animation
I've tried this: isWalkingAnimator.SetBool("isDead", false); but nothing happens