Search Unity

[Released] Unity's first Flowfield Pathfinder

Discussion in 'Assets and Asset Store' started by Glenn-Korver, Jan 28, 2016.

  1. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.

    https://www.assetstore.unity3d.com/en/#!/content/53526



    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.
     

    Attached Files:

    Teila likes this.
  2. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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
     
  3. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.
     

    Attached Files:

  4. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.
     
  5. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    240
    Hey.

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

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    - 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.
     
  7. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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?
     
  8. Maverick

    Maverick

    Joined:
    Dec 18, 2009
    Posts:
    240
    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).
     
  9. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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
     
  10. davidkrings

    davidkrings

    Joined:
    Feb 15, 2016
    Posts:
    12
    Would be interested in that, too!
     
  11. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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?
     
  12. davidkrings

    davidkrings

    Joined:
    Feb 15, 2016
    Posts:
    12
    Right, just found it! Thanks for sharing, will take a look into it later tonight :)
     
  13. wurbaga_2

    wurbaga_2

    Joined:
    Mar 15, 2016
    Posts:
    2
    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.
     
  14. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.
     
  15. wurbaga_2

    wurbaga_2

    Joined:
    Mar 15, 2016
    Posts:
    2
    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.
     
  16. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.
     
  17. Xergz

    Xergz

    Joined:
    Aug 23, 2016
    Posts:
    3
    Hi, I'm considering buying your tool for an RTS game.

    I have a couple questions though:
    1. Is this still actively supported/developed?
    2. How would your pathfinding react to a request for a path leading to a non reachable location?
    3. Is there some form of local avoidance included?
     
  18. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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
     
  19. Xergz

    Xergz

    Joined:
    Aug 23, 2016
    Posts:
    3
    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.
     
  20. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    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.
     
  21. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    103
    Does the Navmesh come out as PNG?
     
  22. giotta

    giotta

    Joined:
    May 31, 2015
    Posts:
    48
    is the dead asset or the developer is still working on us?
     
  23. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    Hey, the asset is not being developed further. If you have questions about it feel free to ask.
     
  24. kuyote

    kuyote

    Joined:
    Mar 5, 2017
    Posts:
    7
    hello, is there a way to generate the map while running? Part of my game places new path's during in the game, so I need to be able to update the path after a new path has been created. Also, I an using bridges, that sag due to gravity, it looks like the lower points aren't being path'd properly. Is there some setting that will allow the path to sag?
     
  25. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    Hey Kuyote, It is possible to regenerate the map. Simply execute the same functions as the Pathfinder in its Awake(). I will add a Regenerate() function to make this process smoother, do make sure this is done after other scripts are finished with the Pathfinder, you could use LateUpdate to prevent overlaps between Update functions. However there will be some issues if for example: you remove some mapped area a unit is standing on, there is no build in mechanism to ensure this process goes correctly.

    I don't know the specifics of your other problem "the lower points aren't being path'd properly" I would need some more info / perhaps screenshots to give comment.
     
  26. kuyote

    kuyote

    Joined:
    Mar 5, 2017
    Posts:
    7
    Here is an example of what the map looks like after the bridge is placed. When I select the location for the bridge to be placed, it's plopped, and then I want to update the map to be able to allow the units to travel over the bridge.
     

    Attached Files:

  27. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    What I expect is happening, is that the raycasting step in mapping the world is missing part of your bridge due to there being some gaps. This could be somewhat solved by increasing the grid resolution, but this would NOT be a good solution. Instead what you want to make is an extra mesh which is a simplified version (like an outline) of your world's geometry, which is purely used for the mapping.

    This will
    1. fix your gap issue
    2. probably increase your performence tremendously. Looking at your image, it seems like the world is being cutt-up in a lot of different sectors while that really isn't neccesary.

    For example see the images below, lets say the first example is your level, with slight diffrences in height around the edges and a bridge (which should have gaps)

    I would reccomend to make a 2nd simple mesh like in the 2nd example where the bridge is a solid surface (no gaps, but needs perhaps a bit more vertices / smoothness for your specific bridge), and the land masses are also flat, you can easily let Unity take care of characters slightly going up and down seperate from pathfinding on the real geometry.

    a diffrent way of constructing your "pathfinding" surface is also fine, its just about the principle of seperating your graphics form your gameplay in this particulair instance.

    Note that I raised the simple mesh just so its more ealisy visible.

    ExampleLevel.PNG ExampleLevelV2.PNG
     
    Last edited: Jan 5, 2018
  28. kuyote

    kuyote

    Joined:
    Mar 5, 2017
    Posts:
    7
    Thank you Glenn-Korver, I had asked someone else for suggestions on how I might fix this, that that is pretty much what they had said as well. I appreciate the help, and the updates to flowfield!
     
    Glenn-Korver likes this.
  29. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Can this be used on unity's navmesh, or a navmesh in general ? I don't use a grid i use a navmesh due to performance reasons. Let me know thanks.
     
  30. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    This tool generates its own grid based on raycast collisions on colliders, it's not designed to work together with a Navmesh.
     
  31. TheCelt

    TheCelt

    Joined:
    Feb 27, 2013
    Posts:
    742
    Ah damn thats a shame :(
     
  32. akavish

    akavish

    Joined:
    Mar 19, 2019
    Posts:
    1
    Hi,

    Just bought your asset and try to make it work in 2D.
    But i can't make it work. Do you have a documentation about 2D ?

    To try, i just used pathfinder.GetMousePosition(); and it allways send me the same value.
    I noticed that the "grid" does not appear on my scene view. Maybe it's because there is no "ground" layer ?

    Indeed i'm making a 2D game with spaceships so my spaceships are not "on" something.

    Can you help me ?
     
  33. shunter55

    shunter55

    Joined:
    Oct 20, 2020
    Posts:
    1
    I would like to have more flow vectors so I can have a more direct path. Is there a way to have more than just the 8 in FlowFieldManager?
     
  34. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    Sorry there is only support for 8 directions / point at neighbouring tiles.
     
  35. cloverstudio

    cloverstudio

    Joined:
    Dec 13, 2017
    Posts:
    4
    Hi, I used your asset for gourp movement,
    but sometimes some unit's seeker.flowFieldPath become null, but others are right(all use pathfinder.FindPath)
    besides, pathfinder.FindPath cannot take effect(maybe ThreadedJob not execute correctly), the flowFieldPath.destination has been previously set;
     
  36. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    Hey Cloverstudio, I do not fully understand your question. It sounds like you are saying that the seekers lose their path / the path becomes null, but only some of them, eventhough they have the same destination. Do I understand you correctly?

    If you want me to help, I will need to be able to reproduce the problem. Is there a project you can share or a video of the demo scene which show the problem?
     
  37. cloverstudio

    cloverstudio

    Joined:
    Dec 13, 2017
    Posts:
    4
    yeah,that's the idea
    sorry my poor English;
    there is a log: "A Selected Unit cannot be located, is it to far above or below the ground?"
    IMG_20211117_121301.jpg

    left two horses did not move, and thier flowFieldPath are null.
     
  38. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    Hey Clover, I send you a direct message (Unity forum conversation), lets continue there for now, so that we dont fill up this thread with a bunch of back and forth.
     
  39. Brainshack

    Brainshack

    Joined:
    Mar 1, 2013
    Posts:
    33
    Some Questions, even though I feel kinda dumb to ask:

    - How do you change Unit speed?
    - Is there some sort of event that is being triggered when a unit reaches its destination?
     
  40. Glenn-Korver

    Glenn-Korver

    Joined:
    Dec 11, 2015
    Posts:
    34
    No worries, feel free to ask.

    There is some baseline code in the Seeker.cs class which you will have to change / amend / override to get your desired results. The main feature is the pathfinding logic itself, the Seeker class is mostly an example of how you can use it to make units move, but you should make your own "version" which matches the needs of your gameplay.

    - There is a MaxSpeed and MaxForce value that can be adjusted to influence the speed, you could introduce an acceleration value aswell to get more control.

    - there is no event at the moment, but in Seeker.cs there is a ReachedDestination() function, which you could extend to create an event.
     
  41. cloverstudio

    cloverstudio

    Joined:
    Dec 13, 2017
    Posts:
    4
    ok
    I'll contact you later