Flowfield pathfinding

Ideas and suggestions for how to improve the Warzone 2100 base game only. Ideas for mods go in Mapping/Modding instead. Read sticky posts first!
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Flowfield pathfinding

Post by Shadow Wolf TJC »

This is a type of pathfinding algorithm that Supreme Commander 2 (and possibly other, more recent games out there) uses for seamlessly moving units around obstacles along the way to its destination. It works very much like a fluid-dynamics simulation.

Here's a link to a video on Gametrailers that showcases this kind of system in action: http://www.gametrailers.com/video/flowf ... nder/62420

From a programming perspective, it seems to be fairly simple as to how it works:

During each frame, each mobile unit would perform a check to see if there's another mobile unit that's too close to it. (Note: the collision boxes of units may need to be smaller than the radius to check if units are too close.) If the check is true, then the unit would try to move away from it whilst still trying to reach its destination, most likely by either moving some distance to the checking unit's relative left or right (depending on whether or not the other unit is towards the checking unit's left or right side relative towards the checking unit's angle of direction), or by moving some distance away from the other unit as its moving towards its destination. (Said distance to move away would increase the closer to the other unit that the checking unit is.)

Edit: I now realize that, even when using flowfield pathfinding, units could still have trouble moving around in spaces that would be pretty narrow for them, as can be demonstrated here. :augh:
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100
User avatar
aubergine
Professional
Professional
Posts: 3462
Joined: 10 Oct 2010, 00:58

Re: Flowfield pathfinding

Post by aubergine »

"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Spik3d
Rookie
Rookie
Posts: 28
Joined: 21 Jun 2007, 04:42

Re: Flowfield pathfinding

Post by Spik3d »

Shadow Wolf TJC wrote:Edit: I now realize that, even when using flowfield pathfinding, units could still have trouble moving around in spaces that would be pretty narrow for them, as can be demonstrated here. :augh:
The first demonstration currently happens at a worse level with the possibility of units getting "caught" on another unit until bumped or given a new order.

And it's a little unclear what the second is really proving. It looks like there might not even be enough space for one to fit through at a time. In Warzone's case, when you disconnect a path with structures, it disables the nodes it covers in some way. So the units would then find a new way around or not be able to make it. You also can't build a structure on the edge of units which would be more appropriate to relate to that demonstration.

But even just based on the ratio of the units to the width of the bridge it'd be a 2-unit wide path in Warzone with a few of the average to larger bodied tanks. And 2-unit wide paths aren't very common in Warzone.