Is there any reason why you play the animation so frequently? Instead, I would use OnCollisionEnter2D() to set the value to true and OnCollisionExit2D to set it to false.
In each of these functions, play the respective animation. If you want it to keep playing, then set it wrap mode in the Inspector to Looping.
↧