Problems Understanding Use, and EquipUnequip Abilities for AI

Dreadnought9999

New member
So I'm trying to develop an AI that has 6 weapons for a first-person-shooter, and I'm getting very confused with how the Use and EquipUnequip work when trying to start them from a script. Specifically the player is either not animating or not completing the animation for shooting, as of now, I can see I'm not receiving any of the callbacks for OnAnimatorItemUse and OnAnimatorItemUseComplete, I am receiving the OnCharacterItemAbilityActive callback which prints whether the ability is active or not, I always get a true and false message instantly.

In regards to Animation I'm using the UFPSDemo animator controller for the AI character, which I've also done with my player character and that works fine, along with that I've set each of the 6 weapons to have the AssaultRifle animator controller that came with UFPS for both player and AI. I should mention I am not using the Nolan character model, but a separate model, in case its Avatar might be causing problems.

I am suspecting my problem lies in not having a clear understanding of the pipeline that follows when TryStartAbility is called, and the Animator parameters "Slot0ItemID", "Slot0ItemStateIndex", "Slot0ItemStateIndexChange" and "Slot0ItemSubstateIndex" and how exactly those are set and trigger the aim and fire animations in the Assault Rifle sub state machine on the Arms layer of UFPSDemo.

Since my character gets constantly stuck in the Aim animation this is for both when the Aim ability is set to either manual or automatic (I've tried using automatic for keeping the AI in the right position). So the shoot animation never plays and I believe never sends the callbacks to ShootableWeapon. In regards to the EquipUnequip, either it won't animate and just change weapon or the Use ability blocks it completely.

Here are my ability settings

1597232973279.png

1597233019757.png

For code I've just been calling this for shooting
1597233283953.png
For equipping I've just been testing with
equip.StartEquipUnequip((int)index)); //Where index is an enum for Weapons

Can anyone tell me if I'm missing something in how I'm executing this, or other possible components that could be causing the issue? Since my player and AI are using the same character model and animation controllers, and the Player works fine.

Thanks in advance.
 
I have a few questions:

- Does the shoot variable reference the Use ability?
- If you set a breakpoint within TryStartAbility does the Use ability start successfully?
- Does the Use ability just get stuck on the active state?
- Does the SlotXItemStateIndex change values?

For reference here's a video on how the animator controller is setup which may lead to some clues as the cause:


Also take a look at this page for shooting troubleshooting:

 
Thanks for your quick reply, to answer your questions:
1) Yes, shoot refers to the Use ability.

2) When you say start successfully, does that imply that I receive the callback for OnCharacterItemAbilityActive? If that is the case then yes, however I receive a message saying Use is activated, and then immediately set to false. Otherwise I can't exactly tell since I can't use Debug mode for some reason, I keep getting this window that says "Select Unity Instance" with no options, and have not found anything for fixing it, I'm using Visual Studio 2017, and noticed this happens when I've imported Opsive packages.

3) In this case, the character gets stuck in the Aim ability, the following is a screenshot of the animator controller when Use is started.
1597322887663.png

4) Slot0ItemStateIndex is changing from 1 to 2 when use is activated, however, the problem I keep seeing is that in order to enter the Fire State, Slot0ItemSubstateIndex must equal 2, and it is never set to 2. I also notice that Slot0ItemID needs to be not equal to 1 in order to exit the Aim State, not completely clear on how much that effects the system.

After more thorough testing using the Nolan prefab, and seeing Nolan work properly, when I added new items to him and tested with PUN, I'm still unable to understand what is wrong with the character model I'm using, especially since it works fine with the Player prefab I made using UFPSDemo.

Could differences in this character's rig be possible causes of problems? I think this one has only a few extras compared to the Nolan rig, I have also noticed different parts of this model have different root bones, whereas Nolan references all the same root transform
1597325463982.png
I'm running out of ideas as to where the problem might lie.
 
Are you getting any messages in the console? The only thing that I can think of is that it relates to the fire direction (third option under troubleshooting):

 
Sorry for the late reply, I see that when I lowered the look sensitivity I do get the character to fire. I do just want to make sure that the look sensitivity does directly correlate to the AI's accuracy and it isn't just a visual to make the character look like it's aiming properly while the accuracy calculations are handled elsewhere. I ask since I set look sensitivity to 0.298 from 0.97, and was still able to hit fairly consistently, perhaps not perfectly, just making sure that's all I would need to adjust the accuracy of the bots or if I would need to manage the AI's accuracy elsewhere or on my own.

Thanks for your help so far!
 
If I remember rightly, the look sensitivity only determines how closely the ShootingWeapon needs to be pointed towards the facing direction before it will fire, which isn't exactly the same thing as adding random inaccuracy to a character's shots. (The actual direction it fires doesn't get modified, so if the weapon happens to be pointing in exactly the right direction then it will be perfectly accurate.)
 
Top