How (often) to call AI Move To for 100 units following player in formation?

Hi,
I have AI units following player in formation. Formation reacts to player changing direction of movement. Each unit recieves Destination vector calculated according to ther array index.

My question is: how would you recommend to call this formation change? Every tick is ideal for smoothest movement, but what would it do with performance?

1 player can have up to 100 units (now.)
There is one human player and 3 AI players (now).
And 100 neutral units

So its up to 500 units that recieves AI Move To function.

My skill so far says: dont do it every tick. Use Event by timer and do it every 0,1 sec or so.
But is there some better way you would recommend? Maybe something else than AI Move To?

I am happy for suggestions of topics to study.
Thank you.

Unless you measure a performance problem there is no performance problem and you can do so. I question if you can keep a very precise formation with MoveTo at all, possibly you want to relax the formation a bit and update every unit, not on tick but say every 2 seconds. Predict a position the AI want to go in a second based on the player character’s velocity. Updating them all on same frame might have a greater performance hit.

2 Likes

Dispersing unit updates across Ticks(), or something like that, would look more realistic as well. Formations wouldn’t be exactly mathematically precise.

Similar to how you want to delay or play formation animations at slightly different times / speeds. No formation will ever be exactly in-sync.

1 Like