AI Fight Scene / MOBs Attacking Each Other

Hello!

I’m prototyping a game right now and I want to make monsters (AI) fight each other. I’ve seen a plethora of tutorials on making the AI attack the pawn, or character your playing, but I can’t quite find what I need to make monsters simply fight each other.

What I effectively want is:

  1. Spawn monsters, Team A, Team B
  2. Monsters fight each other, cast spells & abilities, eventually die off (Team A always win, survival thing)
  3. Reaction to spell effects (stuns, fears, snares, death, ect)
  4. More Monsters spawn, rinse repeat.

In the AI controller I have the OnSeePawn set, which makes it attack the pawn. I have other characters in the map that the AI won’t engage. I am most likely missing something.

Any direction or key words for this type of AI programming (blueprints) would be fantastic. I normally can find what I need via research.

This is how I’d do it, there may be better ways, but if there are I’d be curious too

I’d put a variable on the mobs, team 1 or team 2. If team one, add to array team 1. If team 2, add to array team 2.

Then for targetting I’d do a variable Has Target. If no, get array for the team that the mob isn’t on. For each get vector length to find distance to all targets, use < to find the one with the shortest distance, then tell it move to it and attack.

From there it’s just a matter of adding more tweaks to get what you want.

To spawn monsters, create a blueprint actor that Create Actor From Class, choose your mob as the actor, cast to it and select set team 1 or set team 2. You can make a nice simple construction script effect so that you can place a building and select in the editor what team it’s on too, so that it spawns the appropriately teamed mobs.

Basically what it sounds like you need is that algorithm that finds the nearest target (or however you’d like it to find an enemy) from the other teams array. Once it chooses one from the array you can make it a variable and make it the target to have it en-gable

Does that help at all?

Gives me some direction, I’ll give this a shot.

Thanks for this!

If you still need help, this video tutorial will walk you right through it: