ID:1953992
 
I'm trying to make a formation of 1-40 mobs move towards a specific location. My idea is using a unit as formation leader and calculate the end targets for each mob, call my path-finding algorithm and call movement proc so all mobs move to their spots. Note all mobs have the same speed and formation is scalable.

so the problems/questions are:
1.Is this a good approach or is it outdated?
2.How can I prevent the units from breaking their formation? Because by implementing the above all I saw was the units breaking formation to move through obstacles and reunite at the target point. (I don't mind breaking the formation 1-3 tiles to avoid a tree, but what happened was half my regiment moved from one path and the other took a different path around a mountain... is there a way to tie the mobs to formation leader?)

I'm trying to make a battle system similar to total war, I've done some stuff to optimize my code so the game does not crash in the middle of the battle. It works fine for 80 mobs moving simultaneously.

Also what would be the maximum mobs that byond can handle?
Ok I figured it out, so if anyone is interested in creating something similar the idea is that instead of the units moving each one to a designated end target it just copies the leader movement, but the leader must also take into account the whole formation size.

But an even better way is to use a two-level movement system.
1st level: the leader moves updating the formation slots
2nd level: the formation members call their movement algorithms to reach their updated slots

there's this really helpful book which explains everything and contains many optimizations

http://ldc.usb.ve/~vtheok/cursos/ci5325/lecturas/ Artificial%20Intelligence%20for%20Games.pdf

Also if anyone knows of newer and better methods feel free to share, since this book was written 10 years ago