Download

How to make Simple player chase AI with crowd sensing

For mods: I haven’t found any tutorial in this section of the forum, about AI crowd sensing so I decided to make one.

How to make Simple player chase AI with crowd sensing TUTORIAL

This is what we are going to make:

I’m going to explain in very short, how to make a simple AI character, that chases the player, and if they are multiple enemies, they try to avoid each other, to avoid passing through each other’s body.

So let’s start!

1. Create an AI Character, and add an “AIPerceptionStimuliSource”. In the details panel, check “Auto Register as Source”. Hit the plus sign, and add “AISense_Team” from the list. SAVE IT.
Imgur

2. Create a blackboard and make a new blackboard entry key of type “Vector” called “TargetPoint”. SAVE IT.
Imgur

3. Create a “Chase Player” blueprint based on the “BTTask_BlueprintBase”. Open it and create a variable called “Destination” of type “Blackboard Key Selector” and make it Editable(press the eye button). After that do the following:
Imgur
Imgur

4. Create a behavior tree and open it. Assign to it the previously created blackboard. Make a selector, drag off of it, and select your “Chase Player” blueprint. Click on it, and in the details panel, for “Destination” select “TargetPoint”.
Imgur

5. Create a controller for the AI, based on the "DetourCrowdAIController". Open it and do the following. In the “Run behavior Tree” node, set your created behavior tree. Add an “AIPerception” component to it. Make sure that the “AIPerception” component’s “Dominant sense” is set to “AISense_Sight”. I’m sure it will work by other means too, but this basically assures, when setting the AI Character’s sense to “AISense_Team” that the AI you created, ALWAYS first checks for crowd sensing, and after that for chasing the player. It happens on tick, so don’t worry, it works just fine.
Imgur
Imgur

6. Now just go back to the AI Character you made, and make sure to set the newly created Controller for it.

I am pretty sure there are other ways to do this, but I found this the easiest way.

If I’m missing something, please tell me, and I’ll correct my tutorial.

Have a wonderful day everyone!