- Home /
Set boolean to false when animation changes?
I have an animation event on a boss that occasionally glitches. I have it so that when the player swipes a certain direction while the boss is attacking, the "Hurt" boolean is set to true and the boss takes damage. However if the player hits the boss multiple times the Hurt boolean sometimes stays true, making the boss take damage again without the player doing anything. Is there a way to set the Hurt boolean to false again after the animation finishes and transitions to another?
Without seeing your animation structure and code its more guessing. You could use a trigger ins$$anonymous$$d of a bool. whenever you hit the boss its triggered. If he's in a state without a transition for it, he won't. or add another animation event to the last frame of the boss setting the bool false in any case.
Answer by giulio-pierucci · Feb 13, 2015 at 11:32 PM
If you're using Animator:
for check if animation change, you may check CurrentAnimatorStateInfo
However, this method can't check for animation looping. (you may use for this normalizedtime)
For a better help, post more info