Use remains active after OnAnimatorItemUseComplete event

EagleGamer15

New member
I'm using the Use ItemAbility for a melee attack, I have to have it set to wait for the animation event rather than time because I'm using a combo attack set up.

If I spam the attack button, eventually I noticed that in my animator the animation freezes because the Slot0ItemStateIndex parameter is stuck at 1 instead of resetting to 0 when the animation event fires, which is even weirder because the Slot0ItemSubstateIndex is being reset to 0.

The only clue I've found so far is that the Use ability is remaining as active even after the OnAnimatorItemUseComplete event fires.
 

ChristianWiele

Moderator
Staff member
If you want to wait for the OnAnimatorItemUseComplete event, you have to adapt the use rate of your weapon so the player can't fire before the use is complete. The use rate must be larger than the time between fire and complete event. This way you can avoid overloading / spamming your system.
 

EagleGamer15

New member
But I need the player to be able to press the button again before the attack is complete to start the next attack in the string. Wouldn't increasing the use rate prevent that?
 

ChristianWiele

Moderator
Staff member
If you increase the use rate (which is actually a wait time), the button press will be ignored until the time is up. The button press will be ignored during that time. If you are waiting for the animation event, the animation event has to be triggered. Otherwise you will end up in an undefined state. The demo animator is not robust enough for spamming the attack button. The problem is that it freezes due to missing transitions. You try starting the item use while it is still in use. So, you need to make your animator more robust to cover all possible transitions.
You can also try not using the animation event, but to use a fixed time for ending the use. But still you need to wait for the item use to end before triggering a new one.
 

EagleGamer15

New member
After doing some more tests, spamming the button isn't the problem. It seems to be occurring if I press the button at the same time that the event is firing.

I can't raise the use rate because the player needs to press the button before the complete event in order to do the next attack in the combo.
 

EagleGamer15

New member
After a bit of testing, I've narrowed it down to somehow the Use ability is either being added, or not removed from m_ActiveItemAbilities in the UltimateCharacterLocomotion.

I've also noticed that when it breaks, in Use.cs in the UseCompleteItem method, m_WaitForUseCompleteEvent[slotID] returns true, not sure if that is helpful or related.
 

Justin

Administrator
Staff member
Unfortunately this is going to require me to step through it to determine what is happening so being able to reproduce it would be great. If the use ability is ending though you could place a breakpoint within AbilityStopped to see what is causing it to end.
 
Top