Enabling the Use Item Ability in Code

jaunger1999

New member
Hi,

I'm writing a script that has an ai agent activate the use item ability and have encountered a problem.

I'm using this ability with an assault rifle. Whenever it's activated, as soon as the agent fires one shot it returns the gun to the resting position. The gun does have full auto enabled.
I attached some breakpoints to the uses of the StopAbility function in the Use class, and found the culprit is in the UseCompleteItem function which starts at line 810 of the Use class. So the ability is being deactivated because that function stops abilities whose animations have completed.

Is there any way I can manually turn the use behaviour on and off without this functionality? I'd prefer to not fiddle around with the included Use class.

Thanks.
 
The use complete method is called after an animation event or timer. You could just have it wait for an animation event and never send that animation event, though it will then never complete.

 
Thanks for the response.

I did some more digging in the code and figured out that enabling the "Wait for slot event" checkbox under "Use complete event" fixes my problem. Though I haven't been able to find anything in the documentation explaining what this means.

A few things confuse me about this system.

1. Why does an animation completion event override the timer even when the "wait for animation event" checkbox is unchecked?
2. What does "wait for slot event" mean?
3. I tried removing the animation event with the string OnAnimatorItemUseComplete in the assault rifle fire clip (I'm still figuring things out with the demo animator) but this seemed to have no effect. Maybe multiple events trigger it but I don't know where they are?
 
1. Why does an animation completion event override the timer even when the "wait for animation event" checkbox is unchecked?
The method doesn't know where the complete call came from, only that it was called.

2. What does "wait for slot event" mean?
It is waiting on an animation event such as OnAnimatorItemUseCompleteSlot0.

3. I tried removing the animation event with the string OnAnimatorItemUseComplete in the assault rifle fire clip (I'm still figuring things out with the demo animator) but this seemed to have no effect. Maybe multiple events trigger it but I don't know where they are?
There are multiple use complete events depending on your perspective. You could open the animator file in a text editor and search for the event name to clear them all out.
 
Top