Animation not playing when Player enters a tilemap
A Tilemap has a Tilemap Collider 2D and is set to be a trigger. A script in Tilemap has OnTriggerEnter2D method which sets bool value of Player's animation parameter. It should change Player's animation when enters that Tilemap.
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
other.gameObject.GetComponent<Animator>().SetBool("inWater", true);
}
Transitions between states have inWater parameter. In transition from Idle to Swim that parameter is true and is false in transition from Swim to Idle. When playing the game, inWater parameter doesn't change when Player enters that Tilemap and nothing happens. I don't know what's going wrong here.
Your answer
![](https://koobas.hobune.stream/wayback/20220613060057im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
BoxCollider2D OnTriggerEnter2D 1 Answer
reset destroyed collider after game restart 1 Answer
OnTriggerEnter2D problem 1 Answer
Destroyed gameObject keeps colliding with player 0 Answers
OnTriggerEnter2D at high velocity 0 Answers