[Released] Unity's first Flowfield Pathfinder

The first FlowField based Pathfinding tool for Unity. This tool is designed for pathing large groups of characters on both flat and overlapping 3D surfaces/worlds.

You can dynamically change the environment by making surfaces unwalkable or less diserable with the use of cost manipulation, both through code and painting on surfaces in the editor.

Features:

  • Storing your world in a expandable grid based structure.
  • Supports overlapping 3D surfaces.
  • Flow Field based paths.
  • Steering force based character movement.
  • Designed to be the best option for group based movement.
  • Cost manipulation, control how your characters navigate the world.
  • Path requests are handeled outside the Main Unity thread.
  • HPA* searches, speeding up pathfinding requests, works on multiple layers.
  • Compatible with “Unity Terrain”.
  • One example scene.

Planned:

  • Incorporate user feedback: all feedback is welcome and will help with future development of this asset.
  • Better documentation: Current version only describes the surface level, next update will describe all the neccesary functions and methods, so you can incorporate this asset in your project properly.
  • Quadtree’s: To optimize characters finding their neighbours, which will result in better steering force driven movement.
  • Faster processing of world changes at runtime.
  • And more.

1 Like

To give a heads up, the next update will include proper documentation and optimized neighbour searching through quadtree’s. And I hope to submit this update around february 4th

I have updated the documentation with a description of certain cycles in the asset, and some Do’s and Don’ts. I will update the tool to include this documentation, but it will probably take a week+ before it has been approved by Unity, that is why I included the updated documenttaion in this post. Any feedback or questions are welcome.

2494366–172164–FlowField Documentation.docx (1.19 MB)

Hey guys, the Quadtree system has been submitted today, it took me a bit longer than expected due to other matters I had to attend to and difficulties with garabage collection, so v1.2 should be online somewhere next week. I will also try to include OctTrees for more square world, like an office building.

ps. The quadTree isnt exactly a true quadtree, read the documentation about how it works.

Hey.

Do you plan to support different sized characters, separate and/or in mixed groups?
Have you done any stress tests?

  • different sized characters is already possible, however all characters should still not be bigger than a single tile, as they else wouldn’t fit through 1 tile openings, which the tool assumes. But you can have characters of diffrent sizes, and have diffrent steering forces for them if you want.

Perhaps you mean verry large diffrences (like a huge tank that is the size of 4x4 tiles), that character would get stuck at small openings, currently i’m not working on this issue, and I’m not sure i will, as it is something that could take up quite a lot of work.

lastly, but if your world already ensures the “getting stuck” cant happen, since your world doesnt have openings that are to small, it works just fine with any size.

  • groups: I’m not quite sure what your question is, what do you want to know about them in relation to diffrent sized characters?

  • stress test: There is a part about performence results in the documentation, but you would want to know them beforehand, I will post them here shortly.

yes if you look at the documentation.docx that I posted in this thread feb 3th, there is some performance info there on the last pages. or are you looking for something else/more?

Yes, this is exactly the case I meant. A tank vs troops. If you don’t plan to support it, then is it possible to created several overlapping fields with different cell size? So, as in our example, troops would use one field and tanks another?

I meant having mixed groups, like troops escorting a tank, for example.

The documentation is enough for now, however a demo scene would be great to see (youtube maybe).

hmm, yes it would be possible, but its not the “standard intended way”. I think you could do the following: lets say you want 2 fields with diffrent sizes, you would need 2 pathfinder scripts/prefabs each with their own settings, and you would make sure to call the right one for the right unit. However blocking tiles off on both layers will then get tricky, if I block a 1x1 tile off, how does it affect my 2.3x2.3 layer? this would be something you need to figure out yourself. Same deal with manipulating cost values of tiles, so you would not be able to draw cost beforehand in the editor and apply it on both pathfinders. depending on your project this might/ probably prove difficult?

(1 pathfinder standard way:) mixing groups should be no issue, it would prob more come down to your own gameplay logic, all characters can just follow the flow and have local interacting forces. if you do the multiple pathfinder solution this might be a bit harder, but i dont expect this to be a difficult part.

there is a demo vid of showing the tool’s capabilities, but you might be talking about an ingame use? I’m actually currently working on a little demo/game project that uses my tool, but that will take atleast another 2 weeks before I post it here.

I hope to have answered well, but yeah the multiple pathfinder setup is possible, its just quite difficult depending on how complex your game is

Would be interested in that, too!

if you look at the documentation.docx that I posted in this thread feb 3th, there is some performance info there on the last pages. or are you looking for something else/more?

Right, just found it! Thanks for sharing, will take a look into it later tonight :slight_smile:

Hi,

I consider using your pathfinding for an rts game.

  • is the pathfinding deterministic or would it still yield different results on different machines assuming the game uses a working lockstep model and no physics?

  • the moving objects group seems to clump up to a big unordered ball when reaching its destination. Is sth like formation movement possible ? units don’t need to keep formation while on the move (so they can freely circumvent obstacles), but when reaching the destination, it would be nice if they can have either the starting formation or -even better - some other defined formation.

I’m not a 100% sure what you mean, but the flow field itself will always be the same. how units move may slightly differ as they move an amount based on deltaTime, but this would be true for every tool I think.

Currently there is no formation system, and for now I dont expect to build one soon, but I might build it in the future. If you feel confident enough you could make one yourself, it should be possible as games like (supcom2 and planetary annihilation use flowfields and have formations), but I haven’t researched this topic yet, so I don’t know how much work it will be.

I basically mean this: for an rts multiplayer game one player sends only the input commands over the network and it is expected that all other machines make the exact same computations to not get out-of-sync, i.e. when player 1 says “move unit A to coordinate 3;3” and the local machine needs 70 frames to move the unit and then positions it on 2,9999;3.000001, then all other machines need to come to exactiy the same result by themselves – to every bit of the float values in the exact same number of frames. Lockstep guarantees that frames use a fixed deltaTime and that all machines wait for the slowest one to finish the current frame before proceeding. With this model, some additional things need to be considered, amongst those is the avoidance of method that do stuff with random numbers and avoidance of Unity Physics, as it is not deterministic and will compute (slightly) different results on different machines.

Sorry for the late response, yes the tool is deterministic IF you change 1 part of it.

Currently all pathfinding calculations are made on the second thread of your CPU (so outside of the main loop), however setting a tile’s cost/blocked value is done immediately on the main thread. You would have to move the functionality of changing the tile values to the second thread. This would mean that you cannot always change a tile value the moment you want, but instead add this change as a task to the pathfinding que.

This change would make it so that there could be a small delay for tile changes to happen, implementing this change is quite easy and should be possible within an hour.

Hi, I’m considering buying your tool for an RTS game.

I have a couple questions though:

  • Is this still actively supported/developed?
  • How would your pathfinding react to a request for a path leading to a non reachable location?
  • Is there some form of local avoidance included?

Hey Xergz,

To answer your questions.

  1. It is no longer being actively developed
  2. A non reachable position, would result in the flowfield being unchanged.
  3. there is local avoidance between units only.

Regrads,
Glenn

If there is local avoidance I understand that the video is outdated right? Because it feels like all the entities are overlapping each others. I would much prefer if they would leave space between them.

Actually there are already local forces active in the video, but I’ve set them quite low. You can manipulate how much agents try to push themselves away from others as much as you like. However I don’t guarantee that agents will never intersect, unless you build your own sytem / or use unity colliders. Using colliders though will mean that there are some position changes being made by the engine that my system can’t register, causing agents to potentially fall off the level, only way to prevent them falling int his scenario, would be to place colliders around the edges of your level.