AI Perception Issues / Herd-Sensing

So, I’ve got a behavior tree set up, it works when there is a single NPC using it. It can find a player within sensing range, chase them, stop short and attack, and if there’s nobody in range it moves to investigate and if it finds nothing it goes about its patrol path. Pretty simple and not too polished, but it works with just one NPC in my navmesh on my level. The NPC does not ever react to me unless I trigger one of its senses within its defined ranges/etc.

However, when I spawn in multiple NPCs/set up a group of them, as soon as my character goes into the nav mesh, some but not all of the NPCs immediately start running at me. Way out of sensing range, no other NPC should be able to see me so its not an issue of one NPC being set up to alert others. They just immediately come at me like they are somehow herd-sharing senses as well as picking up on my location despite nobody being in range.

It’s been baffling me for a while, so I’m reaching out to see if there’s something I’ve done that’s just obviously wrong here.

I’ve linked my Behavior Tree below:

The issue appears to me to be in the first section, the ChasePlayer section, as if I disconnect everything else, the issue of them immediately chasing to where I am from a mile away still happens. It is worth noting that I’ve tuned the Sight perception value all over, including the Auto Success Range from Last Seen Location setting, which I’ve tuned down to 0 and the issue persists, although it takes the NPCs infinitely longer to get to me since they are losing track of me constantly on their way with that setup.

Linking a few other screenshots that are relevant I think below. Let me know if anything pops out that might be causing this, it is driving me mad!

Long question many attach. Last image below is link to what I have set by default as AI Percetion senses config. Again, even with auto success at 0, they still move about in the distance, indicating they are sensing something that is prompting them to do something other than just fail the whole behavior tree series. They do not currently have patrol paths set and they are not intended to just randomly move about unless they’ve recently seen something for now, so they should just be standing completely still and sensing nothing until I come into range to my understanding of my setup.

I appreciate anything you think might help, as you can see I am very new to this :smiley:

Lastly, a gif of the issue I am describing.

I haven’t given anyone a patrol path in this, so nothing should be moving at all unless they sense something. I spawned in and did not move and was out of any sensory range I’ve set for AIPerception prior to recording this, but you will notice even the NPCs all the way down the road are shuffling about trying to make their way to me, yet others closer than they are standing still as they should until they too join in on the herd-behavior a bit later.

Hi, from your logic above:

In your behavior tree as soon “CanSeePlayer” is set (AFAIK if its set to false it still counts as is set and will execute, so it does not check for “CanSeePlayer” being true or false, therefore I made a custom decorator for bool checks) you just get the player location and move to that. So as soon as “CanSeePlayer” is set once, the bots will move to the player.

In your “CompleteSenses” function you set “CanSeePlayer” to true as soon as the bot sees anything (including any other bot). Therefore if you have one bot it works as you want since it can only see the player, but as soon as you have more than one bot, as soon as they see each other you set “CanSeePlayer” to true and then get the player location in your behavior tree and move to that.

So you need some sort of either team system to be more general (so if you also want bots to target each other but then you also shouldn’t just get the player location in the behavior tree) or some tag on the player that you check in your “CompleteSenses” function.

I would suggest that you just add some tag (e. g. “Player”) to the player character and then in your “CompleteSenses” function check the perceived actor for this tag.

Thanks so much! Not sure when I undid my check for “Enemy” in that section, and I totally missed it in looking over it because I was focusing on the Behavior Tree itself and the settings for the senses since they seemed to be properly sensing and it was me they were running to, not each other, so the thought never occurred to me that they’d be told to run to me by sensing each other.

Got it working much better now thanks to this!