Issue with bots not attacking

Zilcho

New member
Hi I've been using the UCC and AI kits with no issues up until this point, everything has worked fine.

The issue I'm having is when following along with the Deathmatch AI setup video. The end result for me is a bot that will travel between the way points, if it sees the player or another bot it will look at them, pursue them, aim the weapon at them but wont fire the gun.

I'm having a bit of trouble working out why this could be.

>I installed the assets in order, then the integration, with deathmatch last
>navmesh is fine, the bot will walk
>the bot has a weapon and will equip and aim it. The weapon is available in the deathmatch agent component and the use distance is the same as Ayden (Ayden will attack)
>the bot has the weapon and ammo available in its inventory
>Ive added character layer in with the enemy layer to the character layer manager script - it knows to aim at my character, it just wont attack
>The bot behaviour tree is running and goes to the 'attack' task, "attack the target with the weapon in slot 0"


Any ideas? Hopefully I'm just missing something obvious
 
Wow, I just registered to ask about the exact same problem. Followed the video step-by-step, and everything goes swimmingly until the end, at which point Nolan will aim the gun, but the gun won't fire.

At one point, during debugging, I changed the start and stop types to "Automatic" instead of "Manual", which did allow Nolan to shoot his gun, but then the problem was that he couldn't stop shooting until he reloaded, so definitely not a workaround.
 
To get started does the demo scene work? Beyond that the agents attack with the Try Start Stop Use task. Does that task execute?

If I were to guess my bet is that it is a layer issue - the bots probably can't find a target to shoot.
 
Thanks for the reply. If you are referring to the demo scene from the deathmatch asset where you fight against the bots, that works perfectly. I probably wont be able to get back to my laptop until the start of next year, so unfortunately I cant check the task you suggested here, but hopefully that will help me fix this.
 
To get started does the demo scene work? Beyond that the agents attack with the Try Start Stop Use task. Does that task execute?

If I were to guess my bet is that it is a layer issue - the bots probably can't find a target to shoot.
Hello, we have the same problem. It seems that in the Behavior Designer it says "Attack the target with the weapon in slot 0". The Character Layer Manager seems configured correctly and as mtdiedrich says if we put the use in Automatic it will carry out the attack but even when there is no target nearby. Any ideas?
 
To get started does the demo scene work?

My demo scene works as expected. Agents can shoot.

Beyond that the agents attack with the Try Start Stop Use task. Does that task execute?

StartStopUse does execute successfully, which includes the succesful execution of TryStartAbility() on line ~108.

I'm working my way through debugging right now. Comparing variables between my Nolan and the Aydan prefab when both are trying to shoot, hoping that I can find the difference that way. I'll report back if I do.
 
Okay, I don't have the solution yet, but I have found something. Here's a rough stack trace:

StartStopUse.OnUpdate()
UltimateCharacterLocomotion.TryStartAbility(ItemAbility itemAbility)
UltimateCharacterLocomotion.TryStartAbility(ItemAbility itemAbility, bool ignoreCanStartCheck)
Ability.StartAbility(int index)
Ability.AbilityStarted()
Ability.AbilityStarted(bool enableAttributeModifier)
Ability.SetState(bool active)
StateManager.SetState(GameObject gameObject, string stateName, bool active)
StateManager.SetStateInternal(GameObject stateGameObject, string stateName, bool active)

From that last function, here are lines 282-286:
// Lookup the states by name.
if (!nameStateList.TryGetValue(stateName, out var stateList)) {
SetLinkStateInternal(stateGameObject, stateName, active);
return;
}


I placed a simple debug statement inside of this block of code and found that my agent does run this block of code but Agent Aydan does not. Nothing after the return statement runs for Nolan, so, presumably, there's something there that enables Aydan to shoot. I'll make a new comment ITT if I find the exact solution just so that everyone gets notified, but, otherwise, I'll just edit this comment with updates.

EDIT: Ha, nope. This aint it. commented out everything in this function after line 286 and saw no change in Nolan or Aydan.

EDIT2: Working backwards from SetStateInternal and commenting out one function at a time, I found that Ability.StartAbility(int index) is the first one that breaks the Aydan's shooting functionality. So I way overshot the solution.
 
Last edited:
@suvlimex @Zilcho

Get hype, boys. I've got it working on my end, and it was a trivial change. All I had to do was go into the Ultimate Character Locomotion component for the agent and add a new "Use" Item Ability, so that there would be two of them, then I changed their slot IDs to 0 and 1. Basically, just matching Aydan's two "Use" abilities. If I'm not being clear, the screenshot should help. I hope this works for you.
aaa.png

@Justin is this intentional behavior? I've spent a solid amount of time watching the tutorials, reading the docs, and reading posts on here, and I don't recall ever learning this anywhere. If you ever find yourself revising documentation, this may be worth including. Of course, it's entirely possible (if not outright likely) that I'm just stupid and that this is highly visible information.
 
@suvlimex @Zilcho

Get hype, boys. I've got it working on my end, and it was a trivial change. All I had to do was go into the Ultimate Character Locomotion component for the agent and add a new "Use" Item Ability, so that there would be two of them, then I changed their slot IDs to 0 and 1. Basically, just matching Aydan's two "Use" abilities. If I'm not being clear, the screenshot should help. I hope this works for you.
View attachment 7882

@Justin is this intentional behavior? I've spent a solid amount of time watching the tutorials, reading the docs, and reading posts on here, and I don't recall ever learning this anywhere. If you ever find yourself revising documentation, this may be worth including. Of course, it's entirely possible (if not outright likely) that I'm just stupid and that this is highly visible information.
Yes! You save my day.
Thank you!
 
Awesome! I'm glad that you both got it working!

If you are just shooting the assault rifle you should only need a single use ability. The second use ability are for items in slot 1, the character's left hand by default. With deathmatch only the grenades use slot 1, though in the main character controller demo scene the bow and second pistol also use it.
 
I just ran into the same issue and this thread was very helpful! Was anyone able to get it working with a Slot ID of -1, or do we need to manually add each weapon slot to the agent's Ultimate Character Locomotion component for now?
 
If you are just shooting the assault rifle you should only need a single use ability.

I just ran into this same issue with only trying to use a rifle in slot 0. I had to add a Use ability for Slot 1 in order for the AI to start shooting. Did I miss something in the documentation? Does this mean I have something setup incorrectly?
 
Last edited:
Top