Trigger stuck at full in state machine
I am creating a state machine for a gun.
It has three specific animations I want it to swap between:
Primary Fire ( A boolean based on GetKey("Fire1")
Alternate Fire (A trigger based on GetKey("Fire2")
Reload (A trigger based on GetKey("Reload")
I am having issues where if I interrupt one of these two triggers with the other (As in, I press the hotkey while the animation is playing) it will play out the animation and then stop, with the blue bar all the way full. After looking at this answer I understand that the issue is that a trigger is not being allowed to finish.I have tried clearing the triggers before I set a new trigger using this code as suggested by another commenter, though I wrapped it in a method for easier use:
foreach (AnimatorControllerParameter p in animator.parameters)
if (p.type == AnimatorControllerParameterType.Trigger)
animator.ResetTrigger(p.name);
(This doesn't fix the problem by the way.)
My question is, if I am not supposed to use Triggers unless I am sure that the animation will finish, what do I use? Do I use a boolean to check if the animation has finished and reset to false when it has finished?
I have tried simply running transitions between every state as I saw in this answer, and that does work, but if I have a 4 states (Idle, Primary Fire, Alternate Fire, Reload) that all have to connect to one another... thats a mess! There has to be a better way than using a resetAll function, which is really smelly, and interconnecting every single state, because that is a headache to manage.
Does anyone have experience with something like this?
Your answer
Follow this Question
Related Questions
How do I puse an animation? 1 Answer
How to set the blend tree threshold value during run time? 0 Answers
Continuous keydown in Animator 0 Answers
Animation Running Game 0 Answers
Syncing Animations both playing from Seperate Animators 0 Answers