Getting AI to Call for Backup (AI to AI Communication) SOLVED

I noticed this question has been asked by others but never been answered. It seems Epic/Unreal doesn’t have a dedicated system that can be used for easy DIRECT AI to AI communication. In this case I wanted to find a way for AI to call for backup allies whenever the player’s spotted. The AI allies would come running from wherever they were to the alerting AI’s location and proceed to attack, run, blah, blah. I struggled for few weeks to figure out how to do so but I did! I was and am using a Parent Base Class AI with its Children in this project. Thought that’d be important to note but not sure if it matters. I couldn’t post the entire project’s code as it’s from my job however it won’t be necessary.

This tutorial is crucial before reading further!
https://docs.unrealengine.com/en-US/…art/index.html

First, What FAILED:
I tried to implement this system by using a combination of an 1)Event Dispatcher, 2)BP Interface (BPI), 3) BTT Task, and AIMoveTo node. Only because I thought they would make things more modular. What I think happened is that something inside the AI system was being overridden by my logic. Boy I was wrong…

A. My BPI message was called from the Parent’s AIC and BPI Event with attached AIMoveTo node inside the Child. My print string debugging message would print out but the AI wouldn’t move to the desired location. No error messages whatsoever and everything compiled.

B. Tried putting the logic inside BTT Task to be used inside the BT. It seemed to cause conflict with the AI’s other MoveTo functions.

C. Tried using Event Dispatcher called from Parent AIC and binding an event to it inside the Child BP. The bound event was where the AIMoveTo node was. AI still didn’t move…

Here’s what WORKED:
Inside my AIC I used and OnTargetPerceptionUpdated node. This way I could have multiple types of stimuli coming in that can further filtered with an Get
SenseClassforStimulus node.

Next I added along with the AIPerception component, a PawnSensing and PawnNoiseEmitter component. The PawnSensing allows other controlled AI pawns to sense eachother and PawnNoiseEmitter. Allows pawns to make noise.

I made a separate branch for my AISight sense since I needed to make sure what stimulus was being updated. It was done with AISense_Sight boolean node. To make extra extra sure that stimulus was successfully sensed, I used the BreakAIStimulus node. Because I wanted to make sure that my ThirdPersonCharacter tagged “Player” was sighted/detected, I used an ActorHasTag boolean node. If all three conditions were TRUE, then at the AI’s location(receiver of the stimulus) was used as location of the noise. A MakeNoise node was used since it was the easiest way for me to tag the sound. All AI within the radius I defined would respond to the tagged “Alert”. Had to use PlaySoundAtLocation node to hear a sound I could actually hear.

https://forums.unrealengine.com/core/image/gif;base64
.

I then made two variables of type Name called “Help” and “BackupLocation”. “Help” used as boolean to trigger Backup BT branch and BackupLocation stores vector of which AI allies “report to”.

Next, create matching BlackBoard keys for those variables. Make a branch with sequence node and on top of that node create decorator node that uses “BlackboardBasedCondition”. This is where the Help boolean would either trigger(TRUE) or not trigger(FALSE) the branch. Create MoveTo node that uses the BackupLocation key.

In the hearing branch of my AIC I made a check to make sure that if the AI hears a stimulus with the “Alert” tag, then to set the Help BB key to TRUE and have “BackupLocation” variable equal to stimulus location. It doesn’t work well using the receiver location as my AI seemed to get confused.

Ignore the AllyLocation comment since I haven’t gotten it to work yet. Sorry!

Voila! That’s how it’s done. I hope this will be of great help for those struggling with this.

1 Like

UPDATE
I found a way to get the AI to follow each other to the player’s location. Here’s my updated code below

In the AIC add this. Ignore the print node. It’s just for debugging:

Inside the AIC don’t forget to repeat the process for creating a BB key!!

In Blackboard itself make sure to create the ACTUAL BB key itself and set it as an Object of class ACTOR:

Lastly replace the “MoveTo Backuplocation” node with a “MoveTo LizardAlly” node. Now the enemy allies should follow each other whenever backup’s needed!

1 Like

I noticed since UE forums migrated to a new version that some of my pictures didn’t migrate over. This picture was the first one in my “Update” post. From the AIC