I have set up an enemy AI in unreal engine 5.3 using behavior tree, blackboard and AI controller. I want that when the Enemy sees the player he will be either able to shoot at him or to chase him depending from the distance.
the first two photos regard the task for chasing, the third is the blackboard, and the last is my BT set up. I don’t know if and where i should add decorators for this or if should just integrate the shooting part with the task for chasing. Can someone help me, please?
I recommend checking a post I made where I show a basic Behavior Tree setup in which the enemy AI chases the player, using AI Perception inside the AI Controller for detection.
As I mentioned before, you can achieve this behavior using AI Perception.
First, set up AI Perception (Sight) in the AI Controller so the enemy can detect the player.
Then, in the Behavior Tree, you can decide which action to take based on the distance to the player:
If the enemy sees the player and the distance is greater than the attack range, the enemy should chase the player.
If the enemy sees the player and the distance is within the attack range, the enemy should stop and shoot.
You can implement this by adjusting the Acceptable Radius of the Move To node in the Behavior Tree.
Also, I’m leaving this tutorial series that explains the whole setup very clearly. In the example they use a melee attack, but in your case you would just need to change that part so the enemy shoots when the player is within attack range.