#Group combat system with enemies taking turns attacking the player, and circling the player

1 messages · Page 1 of 1 (latest)

noble nexus
#

Hi there - I've been hitting my head against the wall with this system for a while now, and I'm getting to the point where I'm staring at the blank space in VS rather than the code. It is meant to be very similar to the AI system in games like Batman Arkham where enemies take turns and you can parry/attack them (my system won't have parrying though). I would greatly appreciate it if someone took the time to help me out here. Here are the key classes: https://paste.mod.gg/tetptcytwaot/0

...and attached is a video of what the "not working" looks like:

  • Enemies are not queuing attacks properly.
  • Enemies are not circling the player.
lyric crater
#

So, you are already having a solid base, there's quite a lot of code so let me ask - how are you triggering the enemies to walk towards the player? Is it based on distance? Who makes that decision? Individual enemies?

noble nexus
#

Also I just noticed a problem this is completely wrong

#

on so many levels 😢

lyric crater
#

So how I would do it:

  1. When the enemy is in the attack distance, I would add him to a list, if he leaves that distance (and is in the list - just a safe guard) I would remove him from the list. This would keep a list of enemies that can attack.
  2. In the MeleeEnemyAI I would have a timer to store last attack time, when the Time.time > lastAttackTime + attackInterval then I would trigger attack (look at point 3). I would do that in update.
  3. I would select a random enemy from the list of the enemies ready to attack and trigger attack, then I would add this enemy to another list "enemiesThatAttackedThisTurn". Then when selecting a random enemy again (point 2) I would always filter the list first to remove those that already attacked.
  4. When attack is triggered I would compare a length of both lists - if the size is the same, I would clear the 'already attacked' list. You just need to remember to remove enemies from this list when they are far from player (like in point 1)
noble nexus
#

Yeah I definitely should track who attacks and how long ago

#

Also I've just realised that I'm setting state based on precise distances which means every time anything moves by .00001~ it breaks