Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Released] BFGames: Simply A* Pathfinding! NOW FREE

Discussion in 'Assets and Asset Store' started by BFGames, Dec 28, 2012.

  1. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    UPDATE!

    Next update (with in this week) will come with first iteration of JavaScript Support and example/documentation of how to use it!
     
  2. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    NEW UPDATE

    First iteration of JavaScript Support is already submitted to the asset store! New scripts, scene and documentation! Should be up in 1-3 days.

    EDIT: It is already up!
     
    Last edited: Feb 18, 2013
  3. cristims

    cristims

    Joined:
    Dec 21, 2012
    Posts:
    24
    Yes and YES !!

    Thank you!
     
  4. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You are welcome!
     
  5. devilshaircut

    devilshaircut

    Joined:
    Feb 17, 2013
    Posts:
    4
    The AI script, I see, has a JS option, which I have attempted to use. I attached it with JSPath and Pathfinding, but it appears to have no effect. I can get the pathfinding to work for the character, but the AI file appears to not work for me. I realize that you can't diagnose without code, but is there some special caveat for the AI file with JS? It seems like a piece might be missing.

    EDIT: The character variable is also added; I also tried it with the component removed.

    EDIT2: The main reason I ask this question is because I was able to write my own AI with your package, and it works okay ... but I am guessing your solution is better since you know the optimal way to leverage the pathing functions.
     
    Last edited: Mar 3, 2013
  6. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    The AI script is not made with JS support in mind, it is just one of many examples of how to use the returned Path list. in this case it is in C#.
    The idea of the package is that people should write their own AI based on the returned path, because there is different ways to move around if you use a character controller, a rigidbody or some other approach. If you just add Pathfinding and JSpath, then you are set up and ready, BUT non of the scripts are ever calling a path, so you need some script inheriting from Pathfinding to make something happen (JSGridPlayer is an example).

    As an example script for the use of JS support, it is only the JSGridPlayer script that support and show how to use JS. And actually i would not recommend a heavy use of the AI script as it is a little heavy hehe. :p

    If you can give an description of what your game needs, then i will gladly come up with an example or try and point you in the right direction.

    JS support was also added last, so when i am less busy i will extend the documentation and example scripts for JavaScript/UnityScript!
     
  7. devilshaircut

    devilshaircut

    Joined:
    Feb 17, 2013
    Posts:
    4
    Okay thanks for the quick response anyhow. My AI script is okay, was hoping yours was better is all. :)
     
  8. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Nope guess not, mine is showing the most basic possible way to do. But still if you need any help just ask, i can quickly put together something if needed.
     
  9. devilshaircut

    devilshaircut

    Joined:
    Feb 17, 2013
    Posts:
    4
    Not necessary; thank you though for the attentive customer service.
     
  10. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Thats my job ;)
     
  11. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
    Double the price...
    But I am sure double the pleasure with the next update ;-)

    I should have bought it sooner, that's it :)
     
  12. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    There will be a few nice improvements when i get some time again.

    However the price is doubled because i use a lot of time on support and fixing stuff. So if i wanted to get paid something that was worth, just near, the time going into it, i could not keep it at 10. ;)
     
  13. Aaron-Static

    Aaron-Static

    Joined:
    Sep 22, 2012
    Posts:
    4
    This looks great but I have one small problem..

    How can I rotate the pathfinder 90 degrees to make it compatible with the default orientation of toolkit 2d (XY)
     
  14. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    In short, you cannot. It is made with 3D games in mind I think this is the case with all pathfinding solutions on the asset store at the moment (feel free to correct me). Therefore the up axis is set to the Yaxis.

    However it is possible to do so by changing the raycasts generating the map to "shot" in the z-axis direction instead, but doing so will also need changes for everything else that relates to the y an z axis. Would require some work, but if your comfortable with coding it should be rather easy.

    I've been asked this a few times actually, and it seems like there is a lack of pathfinding for 2D games at the moment, so it will likely be one of the first new updates i will create for Simply A*.

    But as i am busy with my Master at the moment, this update might not come before this summer, sorry.

    On a small note. The way-point based system will work fine for 2D games.

    EDIT: Forget what i just said about summer, i got a weeks vacation! I add support for it in a weeks time!
     
    Last edited: Mar 22, 2013
  15. Fusey

    Fusey

    Joined:
    Apr 2, 2013
    Posts:
    4
    Hi

    I'm new to Unity, Pathfinding and games programming in general (except for alot of tutorial viewing). I have decided to go with 2d Toolkit and was looking for a pathfinding solution before I get stuck in. I was all set to give Simply A* a go but the above post has stopped me in my tracks.

    Also I was wondering what the difference between Simply A* and the free version of Aaron's A* Pathfinding is... which one is more suitable for a 2d project using the XY access. You said the waypoint system is good for that and Aaron doesn't support layered points like Simply A* does from what I can gather.

    I'm a bit confused :confused: and want to make the right choice from the start.

    Thanks!

    Fusey
     
  16. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Well i never used Aarons A*, so cannot answer questions on its capabilities, you need to ask Aaron about that.

    My grid based solution does not support 2D games using the XY axis at the moment. However i did start working on adding a solution for this, but it will sadly take longer than anticipated as i need to change a lot in my code. But it will come with-in the next few weeks.

    The way-point based system does not care about which axis you use, only that you have colliders on your objects. It is really suitable for smaller maps and such, but might be cumbersome for larger levels as they need to be setup manually. But it works for 2D games as well.

    Hope that helped you. If you need a solution right away and waypoints is too cumbersome, then ask Aaron, hes might work with 2Dtool kit.

    Also what type of 2D game are we talking about? If it is a platformer, then the waypoint system will be best.

    -BFGames
     
    Last edited: Apr 3, 2013
  17. Fusey

    Fusey

    Joined:
    Apr 2, 2013
    Posts:
    4
    Hey thanks for the reply!

    It would be a top down, maybe tile based RPG style. The maps wouldn't be that big.. probably room to room style.

    Its going to be awhile before i get anywhere so I'll definitely be back here when its time to do some pathfinding :)

    Fusey
     
  18. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    No problem! For a top down RPG game it will work ;)
     
  19. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    First iteration of 2D support is done and submitted! Should be in the asset store in a few days!
     
  20. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    i will make a city game. there will be terrain and floors. i want to use both pathfinding and waypoint system. i will use playmaker as a state machine to make ai behaviours. i will write my custom playmaker actions. my questions;

    can i use scripts to access your system information like path length, waypoint count.

    does waypoint uses pathfinding too? how does a character go to waypoint B from waypoint A? on a single line? if there is a collider does it use pathfinding to go to waypoint b?

    how do you move character? can i integrate it with mecanim?

    why should i buy pathfinding part if i have unity pro navmesh?
     
    Last edited: Apr 5, 2013
  21. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    1. Yes you can access everything, also path length if you use Vector3.Distance.

    2. Yes, waypoints use pathfinding too. Each waypoint can be connected with as many waypoints as possible.If you want to go from A to B it will find the closest waypoint to both, and find the shortest way.

    3. You move the character as you want to. What you get is a simple array/list of positions. This is done for the purpose of giving the developers freedom to move the agent as they want to. There are simple examples given in the package.

    4. Why should you use it over navmesh? I do not know exactly how you intend to use pathfinding, so cannot answer that. But since you ask, i guess you are not satisfied with navmesh ;)
     
    Last edited: Apr 6, 2013
  22. Admiral-Skye

    Admiral-Skye

    Joined:
    Feb 10, 2013
    Posts:
    32
    I was trying this out, cuz someone is making a random dungeon generator and I wanted to see if this can work when that's released. It seems that the dynamic object script only works for disallow objects and wont turn nodes green if something walkable appears or moves. So if the grid is generated before the dungeon, it won't be walkable. But I think I can just instantiate it after the dungeon is generated and it'll work.

    Though if it's possible, could you make it so the dynamic script works on walkable objects? Such as moving platforms, extending bridge and similar things. That way enemies can go towards you after a bridge is extended or something.
     
  23. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Edit: forget what i just wrote, i must be tired. Actually not a bad idea - ill look into it, should not be so difficult to do!
     
    Last edited: Apr 8, 2013
  24. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    i am new to navmesh, navigation and waypoints. so i do not know details of them.

    assume that i will make a city game and i will have walkin people through random waypoints.
     
  25. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    hi there

    i´m still working on a Dungeon Keeper Game. Now, that i finished the basic Mapbuilding, Scrolling and changing of maptiles.. i need a simple pathfinding script with a Grid function. Yours looks perfect for me.

    I´ve only some small questions before i buy it:

    1.)
    Do you think the performance will drop down when i ant to create paths for 390 moving objects. I´m not talking about path per frame. more a "if path ready, create a new one". So, even if the target isn´t existing anymore (cause another imp already destroed the block), the imp should run there and then create a new path if needed.

    2.)
    How fast is the recreating of the map. Cause many Imps can change the map surface really fast.

    3.)
    Can you add a "fear" system. Like: create a path but avoid lava, cliffs or water for specific objects. Cause not every creature can fly over lava or run through such stuff.
     
  26. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Actually having people walk randomly from one position to another can be achieved with all three systems.
     
  27. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    1. It really depends on how often you call paths, not how many. The thing with this system is that it Queues up path requests if it gets too many at once.
    What this does it to make sure that the games does not lag up and everything else keeps running. So if you suddenly for some reason call paths for all 390 moving objects then they paths will get queued, and the game will handle as many as possible per frame. This might do so that some imps with move later than others. It can however move quite a bit per frame.
    Another note is i don't think this system will be the big problem with 390 moving objects in a scene - so many other things will however probably screw your performance.

    2. So if i understand you right? You want an imp to block a part of the grid? Then you do not need to recreate the map. You will add a script i got in the project which will update the map based on it. So when an imp leaves on tile i will free up that tile and will take up the tile it ends on. But this calculation is a bit heavy so might be troublesome for many units.

    3. If you coding skills is good you can, all code in the project is available. But it is not a part of the project and will not be. It is to game specific, and if i needed to add such things to the project i would need to add 100s features based on such requests (trust me already got a lot!).
     
  28. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Actually thinking about this again. It will have some trouble with updating the Y-axis for objects - so will only work for some types of movement (charcontroller and rigidbody)
     
  29. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    what does colors on waypoint links mean? oneway, two ways? Alt + left click, and ctrl + right click do not work always. what is the rule?
     
  30. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    The link color is broken, unity screws it up somehow. All links should be red, except the ones from the active node, they should be yellow.

    I do not seem to have any problem with Left + alt and right + ctrl. Just tested it.
     
  31. Chaosgod_Esper

    Chaosgod_Esper

    Joined:
    Oct 25, 2012
    Posts:
    295
    Not really.. The DUngeon Keeper system is based upon the mechanic, to DIG the level itself. You select a block. Imps run to it - and destroy that block to get new space for rooms, ways or find underground caves. The whole map is changing everytime.
     
  32. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Ahh i see, the map update is not fast enough for that!

    It would be possible, but again pretty specific - so i would recommend that you write your own system for that. Or actually maybe Aarons system can do that, it is however a bit more expensive and not 100% sure it can, but you could ask him.
     
  33. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    New version accepted:

    Support for the XY-plane (2D games mostly).
    Bug fixes!

    :wink:
     
  34. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    how can i understand that a link is one way or 2 ways? my waypoints looks like;

    $waypoint_01.jpg

    how can i move a waypoint? after i moved bottom right waypoint it draws it's old and new position.

    $waypoint_02.jpg
     
  35. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    if you add this code to WaypointNode it makes it more usable :) in that way i can move waypoints and see the line direction.


    Code (csharp):
    1.     void Update ()
    2.     {
    3.         position = transform.position;
    4.     }
    5.  
    6. void OnDrawGizmosSelected ()
    7.     {
    8.         ......
    9.                 ........
    10.         foreach {
    11.             if {
    12.                 ...............
    13.                                 ...............
    14.                 var directionPosition = Vector3.MoveTowards (position, n.position, 1.0f);
    15.                 Gizmos.DrawCube (directionPosition, new Vector3 (0.5f, 0.5f, 0.5f));
    16.             }
    17.         }
    18.     }
     
  36. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Waypoints are not made to move. You should delete one if its not good enough really. But i can look into it.
     
  37. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    with the code above i can move them and they work fine. after setting all connections, if i have to move a point it not easy to delete wp, add wp, make connections to this wp. it is not easy to find correct waypoint from children but it is a rare case so it is not important.

    also on code changes, if i select a different node from last selected, both nodes are selected. last selection should clear all selections.
     
  38. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You should however never calculate something in the Gizmo draw method. Ill take a look at it.
     
  39. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    thanks. do you have any suggestion for this problem?

    i have a city model and i use waypoints. some waypoints are at the door of buildings. i will make people to walk from one door to another through waypoints. all waypoints use Waypoint tag and Waypoint name. as i examined your code use use this name and tag in your code. so i should not change them. i need to mark waypoints placed to doors so my ai script will find them and select one of them. i do not want to make an array and set items manually.
     
  40. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Might have an idea of how you can do the door thing. But i am not home right now so cannot look in the code - ill get back to you later.
     
  41. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    can you add waypoint tags array to Pathfinder class? so your algorithm can use these tags to find waypoints.
     
  42. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Two ways you could do it.

    1. Just add a simple empty gameobject at each door, tag it with something and save the positions in a list at game start. The easy one.

    2. In the waypoint script, add a bool called something like atDoor, with false as default. Now in the waypoint editor script you can add a GUI button or shortkey that sets a bool, which will check for where you are placing a doorstep waypoint or not. If you are then set the newly created waypoints class variable atDoor = true.
    At start you can run through the list of waypoints and find all that got atDoor = true, and save them somewhere.

    Hope that helped as it is not something that will be added. It is way too game specific, and i would like to keep the project as simple as possible to make it easy for all to use.

    Kindest Regards BFGames
     
  43. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    i prefer second solution. i do not want to add extra gameobject while i can use the waypoint object.

    if i add something to your code it means every updates overwrite my changes. if it is not a part of your code, or your code has not extension points i have to break this code from your development line, and i will miss your feature addition and bug fix. :) hopefully you include source code so i can do everything with manual update of code. that's why i choose products that source code included.

    Waypoint tag list would be nice addition to your product. people could select a waypoint set to disable some of them. it is your product, so it is your decision :) for this price it has good features and source code. so i cannot insist on this :)
     
  44. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Well as an overall feature, i might be able to add it. But there is a few things on my list before that ;) But ill write it on my list.

    But just copy the project to your own folder such that it does not overwrite it, and then have an update version and an edited version.
     
  45. BruceT

    BruceT

    Joined:
    Nov 19, 2012
    Posts:
    2
    Hi Lsse,

    I just bought your asset and it looks fantastic.

    3 things. I am getting the following error when I load JSQuickScene and click anywhere on the ground...

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Applications/buildAgent/work/b59ae78cff80e584/mcs/class/corlib/System.Collections.Generic/List.cs:91)
    Pathfinding.SetList (System.Collections.Generic.List`1 path) (at Assets/Pathfinding/Scripts/Pathfinding.cs:79)
    Pathfinder.FindPath (Vector3 startPos, Vector3 endPos, System.Action`1 listMethod) (at Assets/Pathfinding/Scripts/Pathfinder.cs:306)
    Pathfinder+<SinglePath>c__Iterator8.MoveNext () (at Assets/Pathfinding/Scripts/Pathfinder.cs:203)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    <PathHandler>c__Iterator7:MoveNext() (at Assets/Pathfinding/Scripts/Pathfinder.cs:198)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    Pathfinder:Update() (at Assets/Pathfinding/Scripts/Pathfinder.cs:87)

    The error points to line 79 in the pathfinding script...

    arr[arr.Length - 1] = new Vector3(arr[arr.Length - 1].x, Path[arr.Length - 1].y - 1, Path[arr.Length - 1].z);



    Also, when I load WaypointScene and click anywhere, the player drops down and moves to the first waypoint closest to him and stops. After this he doesn't move at all.

    I havent modified anything at all, just loaded the scenes.


    The third thing is about using JavaScript. In the manual it talks about adding files and checking the JS checkbox. By using JavaScript, do you mean calling the FindPath() void from a JavaScript script? I am still learning JS so want to use it.



    Many thanks for your time!
     
    Last edited: Apr 21, 2013
  46. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Hello, and thank you for the feedback. I know the error and it should be fixed in the newest update! (with in a few days, came from my last update). The thing about the waypoint scene sounds very weird, i will look into it.

    To answer the last question. Yes you need to add the pathfinding script to units that are going to find a path and check the JS box in the inspector. Then you can call the FindPath() method from what ever script you want to. What it does is returning an array (which is buggy i see in JS) with positions of the path, they are returned to that exact script, which can be inherited.

    If you need an example, then just PM me and i can help you out with that.
     
  47. silva_raptor

    silva_raptor

    Joined:
    Apr 21, 2013
    Posts:
    12
    Hi! I am using your asset for a little experiment (and hopefully, a future game) and I love it. It has saved me from a lot of problems.

    I think it could be interesting to implement a way to serialize and load precalculated Node Maps, so you don't need to generate all the Nodes every time you load the scene. It could save a lot of calculations and reduce load times. Mi PC takes almost 9 seconds to launch a simple scene with a Map generated over a 1000x1000 terrain with tilesize = 2. When I'm debugging my project that wait is killer. :p
     
  48. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You are right! It is something i am looking into though! So dont worry :)
     
  49. rosevelt

    rosevelt

    Joined:
    Oct 23, 2012
    Posts:
    47
    Hello,

    A quick question,
    Levels in my game are all procedural generated, each level has ~10 regions of about ~500 objects each.
    The objects within a region positioned in a maze like - so most objects are blocking access and some allows.
    It is a space scenery and I'm looking for a way to have NPC spaceship fly from point to point within a region.
    regions are individual and need no path finding between them.

    So when a level is loaded, the grids for all regions need to be calculated.
    How well it is suitable and how well can I expect Simply A* to perform for the above?

    Thanks
     
  50. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Well i need a bit more information on how the levels and spaceship flight works. Do levels have various levels, like floors in a building? Then it wont work. Do spaceships need to find its way in "space" such that the A* should find its way in all three dimensions? Then it wont work, and i think you need to write your own ;)

    Else if these two are not a problem it works fine with procedural generated levels. What it does is at start drawing the map using ray casts. So either you generate your level at Awake() or wait for the level to be generated and then instantiate the assets pathfinder prefab.

    I did use the system for a school project where we auto generated the levels and it worked fine.