Make multiple humanoids move in formation

I was creating my game earlier when I ran into an issue. When calling my units to move to a location that they can’t immediately walk to and use path finding service, they all chose the absolute closest path. Is there any way that they can move as in unison to where they already are? Demonstration below shows (red) which I don’t want and (blue) which I do.

1 Like

First of all, get a center of your formation, then get the relative position of your units in that formation to the formation’s position. After that create a single path from the formation center and make units follow this relatively. Use also a bit of trigonometry tho, so the units will be still in the formation, if they hit the wall, make them follow the closest unit to the next point. If you want to know what did i mean by the trigonometry, ask me.

Ok so what you’re saying is draw a path from the unit’s center to the destination in a pathfinding sort of way, and then offset the units relative to that path? But then some unit’s would be inside of the wall because it would still be hugging the wall. I wish there was some way to tell pathfinding the size of your unit so it calculated that too :-/

You have agentParams tho in pathfinding and pathfinding modifiers too! Why aren’t you using them tho?
Imagine that formation is one big unit and it has own radius.
Or just create a pathfinding modifier boxes which will shrink the gate’s entrance for pathfinding (depending on a cost), but then you must set agentParams.Radius to some small integer

Agent’s params

1 Like

But if you don’t like this idea just iterate through points, get angles with Atan2() function and then send 2 Rays on both sides and find the “balancing” position.
Disclaimer, might be quite expensive, if the path is very long, so limit the checking range(iterations).
Is everything clear?

Oh my god. I had no Idea agent parameters existed and I now re-like roblox pathfinding. Thanks!