Hi there! I was wondering what some of you would suggest for implementing a feature to decide which enemy should attack the player. So in a group of enemies i want only 1 enemy to attack the player at a time. The enemy which should attack the player should be the closest enemy to the player. Or if the closest enemy to the player is playing a hit reaction or dead it should be the 2nd closest enemy. I was just wondering how to go about this. I already have syestems in place for knowing if the enemy is reacting or dead and the closest enemy isn’t very hard to do. I’m just not really sure about how to make the enemies work in a team i don’t really know where to put the logic for it.
Hello,
So, you can use the GET DISTANCE TO node and place it in a looping function that will instruct Unreal to keep track of all enemy’s proximities.
Keep in mind that if all the enemies are of the same class, then you will have to break the arrays with FOR LOOP functions or manually break them yourself.
Then you can create a behavior function/tree for the enemies that evaluate whether to attack or wait, depending on if their distance/hit react Boolean returns as TRUE or FALSE.
The main thing i’m wanting to know is where do i put the logic for the enemies working in a team sort of way where they’re attacking 1 by 1 and communitcating with eachother (sort of) Because in the future i also want a way for the enemies to be able to call over other enemies if they get hit to.
We’re crossing wires or you’re not understanding what I’m saying.
You’re going to put the logic into the BP of the enemies. Though I’m not sure you fully understand how blueprints of multiple actors works. I could be wrong and be misunderstanding your meaning.
Regardless, as mentioned before:
- Keep track of the player’s distance with the GET DISTANCE TO node.
- Create a behavior tree/function that runs through the members of your ENEMY ARRAY.
- Whichever member is closest/2nd closest will attack.
Ohhhh i understand now thanks!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.