Creating AI for Total War like game (unit formations)

Hello guys!

I’ve been using Unreal Engine for quite some time and really had no struggle working with games with no AI in both blueprint and C++. But now I want to try to create game which resembles Total War system of one unit (unit formation) having bunch of units. So, to implement it I created spawner actor which spawns 20 units in a row and puts their reference into actor array. Every unit is controlled with instance of AIControlled. It is set when I select any of unit with mouse click I get selected whole array of units through spawner actor and when I right click on map spawner actor is sending DesiredLocation to MoveTo sequence in Behavior tree to each of AIController (with addition to DesiredLocation of their distance between each unit so that they could keep formation in row). So, all is working fine, except that they are not moving simultaneously and they tend to bump into each other, which is breaking formation while moving. How can I fix this? But more important question is what is the best way to create AI so that units will not break formations? Any kind of suggestion would help!

BTW any kind of functions like Simple Move to Location will not do for me, I only want to work with Behavior tree, cause I need complex stuff later.

1 Like