Need Help With Enemies Avoiding Each Other

Ever since I began my current melee-based project, I’ve tried many different approaches to try to stop enemies from bunching together or forming conga lines. For a while I used a trace/navmesh line-check hybrid function to determine the adjusted Move Goal, but ultimately I am not happy with it. I was excited to learn of a controller variable (can’t remember the name right now but its from Interface_Navigationhandle) that assigns extra cost to paths currently used by it, so pawns will tend to stay away from each other’s routes. That turned out to be another dead end as its defined in cpptext and therefore to my understanding, only available to licensees. Then I learned of a path constraint called BiasAgainstPolysWithinDistanceofLocations but it seems to do absolutely nothing. This issue with pawn avoidance is crippling how my game operates and I’m becoming desperate for a viable solution, and I would greatly appreciate a nudge in the right direction from someone with experience in the matter.

You might consider moving all the enemies in coordination with each other. You can take a look at how my game moves characters together: Himeko Sutori May 2017 update -- alpha gameplay footage - YouTube. I did that by using a few classes: a pawn class, an AIController, and a team controller that tells the AIControllers where to move the pawns to. I’m sure you don’t want anything that structured, but you might still consider moving all nearby enemies as a group.

Maybe every few seconds, you could check for enemy pawns within a certain distance of the player. Make a class that’s an enemy team controller, and have it tell the enemy pawns’ AIControllers where to move to. If they all move in coordination, with orders given from someone else, they can implement tactics like surrounding the player in melee, or holding position and taking cover until reinforcements arrive.

It’s funny you mention that technique, because I worked out (on paper) how to implement a sort of squad-style pawn spawning/movement that I want to prototype on my next project just last week (using a squad manager that handles all squad-level movement etc.). It may work for my current needs also, but I was kind of hoping for something a little less intensive and more ‘individually minded’ - the enemies in my current project are rag-tag cultists and zombies, so having them move in a regimented manner wouldn’t make alot of sense. I may just end up going back to linetrace/navmesh linecheck and work on refining that, as it mostly worked except in a few instances where it would just look rough, it just annoys me sometimes how many potentially useful functions there are in UDK that for whatever reason just don’t work as advertised.
Thank you for your advice and good luck with your game, it looks great!

Matrices is a important word here.

Structs of lines , and the struct of a line would be of pawns

something like this

Struct FormationY
{
LinesX array LinesX;
}

struct LinesX
{
Pawn array PawnsInLineX;
}

See thats a matrix of x and y that would be a formation.

I post this because i think you are asking how to make formations with AI, well that’s what i read more or less sorry i read fast. : P

then you would make a function called GetPawnXAndY(MyPawn pawn); returns a vector2d of x and Y and with that that would be for instance x4 and y6, position would be depending of those 2 variables. ima favorite this page since it’s usefule for me lol.