Search Unity

[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
    It creates the grid based map, based on colliders, collider object tags and raycasts. So you can just generate your level in Awake() and then it will automatically create the map afterwards.

    The waypoint map can not be auto generated at the moment.
     
  2. Polantaris

    Polantaris

    Joined:
    Jun 25, 2013
    Posts:
    18
    I don't think I need the waypoint map, as it's mostly a two-dimensional plane that the generation is done in. Would I be able to make the grid update as time goes on? So for example I intend to give the ability to tear down walls, can my grid be updated as that happens? How costly would that be (does it recreate the entire grid, or can the grid be updated for what is newly traversable)?
     
  3. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    It is possible to update parts of the map only. For performance i dont suggest doing it more than af few times per second for smaller areas though.
     
  4. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Hi, i have done a fresh Import of your ai system into my Project and getting some errors:

    $Screenshot (1).jpg
     
  5. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    It is because you already got a class called Pathfinding somewhere in your project.
     
  6. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Ah, this could be. Thank You.
     
  7. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You are welcome!
     
  8. 3

    3

    Joined:
    Sep 16, 2012
    Posts:
    387
    This looks awesome, I am definitely thinking of buying this.

    Quick question though, does this work with mecanim animations? Or just legacy, and are animations already set up? Or are we supposed to add those ourselves to the AI's?

    Best of luck,
     
  9. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You can make it work with whatever animation system you want.

    However you need to set it up yourself. The system is what it is called, simply an Astar pathfinding system with map generation and some examples of how to use it.
     
  10. AozakiKyuuji

    AozakiKyuuji

    Joined:
    Sep 21, 2012
    Posts:
    15
    Hello again!

    I have a minor problem, and am not sure what's causing.

    In my map, I've set my enemies to spawn at a certain location. Imagine PacMan's ghost spawning area. It's in a box, with a middle opening at the top. Problem is, when my Player is somewhere below the box, the enemies doesn't know how to go north, and get out. So it just keeps running into the wall.

    Any idea if this can be fixed?
     
  11. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Could you post a picture of it with the map being showcased?
     
  12. AozakiKyuuji

    AozakiKyuuji

    Joined:
    Sep 21, 2012
    Posts:
    15
    $StuckEnemies.png

    Here you go. As you can see, in the building on the bottom left, a bunch of characters are stuck. Same goes to other buildings though it's harder to see as they're stacked.
     
  13. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    That is kind of weird.

    Is the player the small guy below standing inside the "red field" - if yes then that might be the problem (which is a bug).
    Else if you mail me the project i can take a look at it. It can be a lot of different things and hard to say without looking at the code and complete level setup. Write me at bfgamess at gmail dot com
     
  14. AozakiKyuuji

    AozakiKyuuji

    Joined:
    Sep 21, 2012
    Posts:
    15
    The player is at top right of the XYZ arrow in the middle. As for the codes, I did not adjust anything other than the options given in the Inspector. If you still need it, then I'll have to find a way to extract this since I'm a newbie and everything's everywhere.. lol
     
  15. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Well it should work then so something must be wrong in the setup. So i will need the project to help sorry :D
     
  16. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Hi

    How can I add and remove points at runtime (waypoint system)?
     
  17. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You cannot, well you could code around it if you feel like it :D
    It is the grid based system that is made for dynamic map changes (as it says ;) )
     
    Last edited: Oct 12, 2013
  18. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Without removing points at runtime, what about block certain points, is that possible?
     
  19. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    The problem would be that it will also block all its connected points then. It is possible but you will need to code it into the way point nodes yourself.
     
  20. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Thats what I want I think...

    In fact what Im trying to do is build a path/road (in a isometric city building game) and put some peasants wandering over the path. Is that the correct approach?
     
  21. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Sure they can do that.

    But for an isometric city building game you should use the grid based version really, You can update the map dynamically then as you build new stuff.
     
  22. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    But what about the movement? I mean, I don't want to have objects moving "freely" on each grid, I want them to move "like a robot", can grid based version do that?
     
  23. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    <

    Yes. Just just define a list of how they can move and call a path for each point, when they get to the last choosen one. You can also choose not to let them move diagonal.
     
  24. Lyje

    Lyje

    Joined:
    Mar 24, 2013
    Posts:
    169
    Apologies if this sort of thing has been asked/answered before (I saw a similar question on the first couple of pages but it wasn't quite what I was wanting to know):

    Is it possible to have a 3D dynamic grid solution with "teleport"-type objects? Specifically, a large 3D space full of dynamic objects (large and small) but with an overall structure to the map defined by a network of wormholes.

    Cheers!
     
  25. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Not sure i understand how you want it to work really :D I mean like a flying space game? then no.

    But you can have a map being changed as you move around objects.
     
  26. saifis

    saifis

    Joined:
    Oct 11, 2013
    Posts:
    6
    Sorry to bother you, but I am having trouble with applying the gridstyle pathfinding in my project.
    I am trying to make all Enemy objects come at me when I press the P Button,

    1. Map(plain Plane object) is about 20x20,
    2. Tilesize is set to 2,
    3. Ignore tags are set to my Character Controller and Enemy object,
    4. confirmed that there are several nodes in green in my Scene


    However when I press P to Find a path, I get an

    Code (csharp):
    1. Empty Openlist, closedList
    2. UnityEngine.MonoBehaviour:print(Object)
    3. Pathfinder:FindPath(Vector3, Vector3, Action`1) (at Assets/Pathfinding/Scripts/Pathfinder.cs:256)
    Seems that Pathfinder can not find any nodes, it was my understanding that the green squares that can be seen where the nodes. Am I miss understanding something?

    Here is my Code that has been attached to the Enemy Object,

    Code (csharp):
    1. public class EnemyScript : Pathfinding {
    2.  
    3.     private GameObject player_controller;
    4.  
    5.     // Use this for initialization
    6.     void Start () {
    7.         player_controller = GameObject.Find("Me");
    8.     }
    9.    
    10.     // Update is called once per frame
    11.     void Update () {
    12.         if( Input.GetKeyDown( KeyCode.P ) ){
    13.            
    14.             FindPath( transform.position, player_controller.transform.position );
    15.            
    16.             if( Path.Count > 0 ){
    17.                 Move();
    18.             }
    19.         }
    20.     }
    21. }
    If there is something in the log that I have missed that covers it, please nudge me in the right direction, thanks in advance.
     
    Last edited: Oct 14, 2013
  27. Lyje

    Lyje

    Joined:
    Mar 24, 2013
    Posts:
    169
    A space game, yes. Does your package work at all in such a situation, or is it just that it won't really handle wormhole-type setups?
     
  28. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    If it is a game where you can fly around freely in space (Full 3D space not connected to the ground) Then not really.
    For a space game a map for your game could take up extensive amount of memory. Overall A* in a large 3D grid can become a problem.

    Don't think you will find a solution for it on the asset store, and probably need to write on yourself ;)
    You could partition you space into box areas, and then use steering behaviours to move around the partitions. Or create a 3D grid for your map and use A*, but be careful of the size.
     
    Last edited: Oct 15, 2013
  29. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Does it support flash export?
     
  30. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Should work on all platforms.
     
  31. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Sorry for the late reply, i somehow missed it!

    Seems like your doing most of it right. And yes the green spots should show available nodes. Could you mail me a picture of the scene and the green nodes to bfgamess at gmail dot com so i can see if i can spot the problem?

    There is one thing you need to fix though for it to work after we fixed this, you put this inside your Input check, should be outside and ran every update or fixedupdate:

    if( Path.Count > 0 ){
    Move();
     
  32. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Just bought this asset. It's well documented and the code is well organized and readable. I was able to add it to my project quickly and it works as I expected. Thanks.

    I'd love to be able to smooth the generated path to remove that typical A* jagged result. I think it's easy as long as you can sample points on the grid. Any suggestions?
     
  33. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    First of you could use some smoothing methods when he is moving diagonal or changing direction, would be easiest i guess. It is rather easy to check if the next one or two index'd path nodes will make him move in another direction.

    If you want to sample nodes around the path, then i can add a method which will simply check if a node can be used based on position + tile size direction. Would that be fine? The look-up should be instant and not cost any performance.

    I can add this to the package tomorrow if you want.
     
  34. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    By the way all, i am working on a deluxe version of Simply A*: Simply A* Pro.

    While implementing this, i will also add and fix stuff in Simply A*. So a large change to Simply A* should happen with in two months.
     
  35. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630

    Yes, I believe I can add the smoothing I want if you add sampling nodes around the path. That would be great.

    Other things I noticed...

    1. I wish there were some visual way in the editor to set the min, max points for the path finding grid.

    2. Generating the grid works fine if my level doesn't have ceilings. I added a ceiling and placed the grid at the correct height. The green boxes show in the editor at the height of the floor however my AI walks on the tops of my ceilings outside the level. Wondering if I've set things up incorrectly. Perhaps I need to change my geometry. Any suggestions?

    Looking forward to a pro version. Would love to have dynamic node based. Can you talk about any new features?
     
  36. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    I will look into sampling points this weekend then.

    1. At the moment the amount of grid points (like 100x100 for example) is based on Start Position and End Position coordinates divided by Tile Size.
    If i create a visual editor it will be a pro feature.

    2. Sounds weird if the green boxes shows at the floor. Is your max Y height set to less than the ceilings Y height? Mail me a picture of it at bfgamess at gmail dot com if it keeps happining.

    Overall a lot of new features like steering behaviours, multi layered 3D pathfinding, multihreading, fast dynamic map changes and so on will be pro features.

    Simply A* was created to generate a map and then return a path list with positions thats all, and that is why it is not priced in the same range as many others. And as much as i like to give all new features to people with Simply A*, then as a freelance programmer i also need money for food and rent :D
     
  37. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630

    1. OK. Great. I'd buy a PRO version instantly.

    2. I'll send a screen shot later today. Thanks.

    3. New Features.. steering behaviours, multi layered 3D pathfinding, multihreading, fast dynamic map changes and so on. Sounds great. Simple A* is perfect as it is and I totally understand what it is and why it is priced as it is. I'm still very happy with the purchase and will buy PRO when it's ready.

    4. When you do PRO, be sure to keep mobiles in mind and watch memory usage and allocation. :)
     
  38. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    As mentioned in my WIP post, then two of three solutions will work great on mobile. And the 2D solution will be made with mobile in mind especially.

    And i will watch memory usage like a hawk! After working on our own unity voxel engine over the last 9 months for our game Gunjitsu, ive become obsessed with memory usage haha!
     
  39. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Hey,

    When is the multi layered grid due? Want to switch to Simply A* but that's a must have feature for us. Love the simplicity - comes across as far more mecanim friendly (in our implementation atleast) than Unity's built in.
     
  40. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    What's wrong with the built in pathfinding and macanim? What happens?
     
  41. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Found it very awkward to set up navmeshagent on an animator that has root motion
     
  42. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    First version of Simply A* Pro should be out mid/late November.
     
  43. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Sound. How should we expect the implementation to work? Do we define the layers ourselves or will it be part of the generations
     
  44. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    You define them you self, as well as tags, and then set how the map generation should react to them. It is extremely easy. I will upload a video showing how it works after the weekend (In the WIP thread).
     
  45. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Cheers, lookforwards to seeing that. Implemented everything now, was a very smooth process. Pro will definitly be a day one purchase for us :)
    As a final question, when you mention steering behaviors in the pro version, does that mean you intend to include smoothing on the paths? Or will I have to try hack that in myself :p
     
  46. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Smoothing is really not a steering behavior, but i will try and create some smoothing as it seems important to people ;)
     
  47. oysterCAKE

    oysterCAKE

    Joined:
    Dec 3, 2012
    Posts:
    149
    Ahh cool. Was planning on having a crack at implementing the sort of changes Gamasutra suggested, but I guess I'll hold off on that one now. Put some loose steering in so it's not too rigid :D
     
  48. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Hey guys i created this method:

    public bool IsTheClosestNodeWalkable(Vector3 pos);

    It can be used to sample nodes around your path.
    Simply add a Path[index] position + a Vector3 containing tile size in a direction to find a neighbor node.
    Or create a smooth path with a bezier curve or something else and check if each step is walkable.

    I will add it along with a few fixes to the app store tomorrow.

    For the pro version i will add something better ;)
     
  49. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    Great. I'll have look once it's on the app store.
     
  50. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Submitted 1.4.

    With sample node method and new way of drawing the map