RTS: Mass Unit Movement Marching Order Types

Hello All,

I’m trying to integrate a mass unit movement into a pathfinding system. Currently all units moving in a group move to the same spot called on by the mouse raycast.

Currently I’m having a bunching-up effect when the units reach their destination. Some units never reach their destination and try to get around the unit in front of it. Currently I’m concerned about the on arrival movement, and not how they form a marching order during movement.

My current solution is spacing out each unit’s waypoint when it is broadcasted by the mouse’s scripting. Basically units reach their destination by doing the following waypoint transformations. Here are some diagrams:

Column
X X - Even 1, Odd 1,
X X … 2, … 2
X X
X X

Row
X X X X
X X X X

V-Shape
X
X X
X X X
X X X X

Line
X
X
X
X
X
X
Row
X X X X X X X X

The current issue is the transform needs to be adjusted somehow if the waypoint transform goes off a level of elevation. I suppose I could use raycast Vector3.down, from each waypoint to adjust them through the ground, the only issue with that is if the waypoints were adjusted into a wall. Obviously each system has its technical considerations.

Another solution would be to adjust each units stopping-distance from the waypoint. So unit one is 1 unit away. Unit 2 is 2 units away, unit 3 is 3 units away and so on.
EX:

Waypoint - 0 <—1 <---- 2 <—3

I was wondering what solutions you may have found in your mass movement interfaces, and what works best. I’ll try to post some code later today.

I’m not entirely sure what to tell you. I took a long time awhile back trying to figure out a system like this. I had a list full of Vector3 points, then I had a system for each unit to figure out which one to pathfind it’s way to. The list could them be expanded to include more points in case there were more units than points, it could create more points. I got stuck on this feature, trying to create more points from nothing. I suspect I needed some matrix math, but I never figured it out. I can’t really offer much help, but I think it’s a very cool idea to try and I’d like to help in any way I can, and the best of luck to you!

I used a double column to transform way-points. This worked perfectly with a few bugs. They need to be spaced out based on the colliders. Some parts of my game use narrow hallways which messes with this column pathfinding.

// Credit: Angry Fox Games
public static class MassPathfindingTransformUtilities {
	public static Vector3 ColumnMovement(int unitorder)
	{
		Vector3 ReturnVector = new Vector3();
		int columnnumber = unitorder/2;
		// Even Logic
		if (unitorder % 2 == 0)
		{
			columnnumber = columnnumber -1; //because the column starts from zero logically
			ReturnVector = new Vector3 ((float)columnnumber * 1.25f,0,1.0f * 1.25f);
		}
		// Odd Logic
		else if (unitorder % 2 == 1)
		{
			
			ReturnVector = new Vector3 ((float)columnnumber * 1.25f,0,0);
		}
		// Error Logic
		//else
		//print("Error! The math is funky!");
		
		return ReturnVector;
	}
}

The issue is if the units are going down narrow bottlenecks the pathfinding will get stuck at these bottlenecks causing a traffic jam. Also if the first selected unit is behind the others, weird pathfinding will occur.

The only solution I see is to avoid narrow hallways and doors in level designs, though a few might present players with a strategic choice.

Thanks

Off the top of my head, you can try something like this…

If you have i.e 9 units selected to move… when clicking on the terrain, build a grid of 3 x 3 transforms or a grid matching whatever formation your units are in, each transform will be a destination for each unit.
Set the unit’s target destination to it’s correct transform… then move the units.

If your units can collide, it gets a little more complex, you can change it so as unit’s arrive at the grid, you can fill the grid up in an orderly fashion.

To move units cohesively in the same formation, create a leader and calculate/lock the offset to that leader’s position.