Opponents attack the player one at a time. Others wait their turn by circling around.

IceTrooper

New member
Hey!
I recently started using Behavior Designer for my main project. I made a simple mechanic for detecting a player, approaching them at close range and melee attacking them. I need to add an important functionality for the behavior of a group of opponents and I am wondering how to do it.

Behavior:
When a player is detected by multiple opponents, they should attack one at a time (set by a variable how many at a time can attack simultaneously). While a particular opponent is attacking, other opponents are waiting for their turn by circling around the player (more dynamic gameplay). When the opponent who is currently attacking runs out of time/stamina/other conditions another opponent should be drawn. The opponent who was attacking should step back and start circling around the player with the others, and the newly chosen opponent should come closer and attack.
Additionally, if the player attacks another opponent than the one currently selected to attack, the attacked opponent should decide whether to take over the attack role (and defend themselves) or flee.
1637141373282.png

I would like some help writing out how I should go about this because I don't know how to start. I can create my custom tasks but don't know what the approach should be.

I have all the extensions for BD (Movement, Tactical, Formations) and I also use UCC (Third person) for the enemy controller. I see that there are examples of group behavior, but I don't know which group to use (I noticed that the group is handled differently between Tactical and Formations extensions) and how to handle it in runtime... and that described case. ?
Thank you in advance.
 
In this case I think the team tree from the Deathmatch AI Kit is the most applicable towards your situation:


In this tree the agents will move in a group formation and issue an event if a teammate has been attacked. Your approach would be similar in that you'll want to use the event system to determine if the other agents can attack. This would be a new conditional task that indicates if the agent can attack. The agent currently doing the attacking would send the event when they are done attacking.
 
In this case I think the team tree from the Deathmatch AI Kit is the most applicable towards your situation:


In this tree the agents will move in a group formation and issue an event if a teammate has been attacked. Your approach would be similar in that you'll want to use the event system to determine if the other agents can attack. This would be a new conditional task that indicates if the agent can attack. The agent currently doing the attacking would send the event when they are done attacking.
Thank you for your reply. I read it a long time ago, when you posted it, but it took me some time to wrap a head around that problem. As you mentioned, I checked out how it was solved in AI Kit. It was a good resource to check increasing my knowledge about the Behavior Trees.
After all, I ended up writing a custom AiDirector script that checks if a particular mob should attack or not, based on many different factors. A mob is starting/ending the battle and using conditional task to check if it should attack.
 
Top