Search Unity

A* Pathfinding Project 3.0 is Released!

Discussion in 'Assets and Asset Store' started by half_voxel, Aug 10, 2011.

  1. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    This system is great, but the list graph needs serious improvement. The grid graph is much better.
    Also i was wondering on how to implement obstacle avoidance on top of the AI to avoid objects that "do not" update the graph for specific small cases.
    For example: if you need to avoid direct contact with an agent but you can't update the grid graph because if you do that the agent controlled by player input won't move when the player requests if the agent is isolated into an unwalkable are created by the "DynamicGridObstacle" instances. That happens a lot in my tests so... Any ideias?
     
  2. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    The best way is to add another local avoidance system on top of it (such as UnitySteer which is available for free).
    I'm also trying to get my own local avoidance working, see my latest blog posts.
     
  3. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    I think UnitySteer is just too much for that. I solved the issue with a very small raycast script.
    But, what about all those Debug.Logs, I change the settings to only errors, but it still fires tons of logs.
    If I build a final executable will I need to go hunt and comment all the logs into the scripts?
    if so, not good for future upgrades.
     
  4. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
    Aron, can you post the "what's new in 3.0.7" list please, or a link.
     
  5. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Sure, here's the changelog (though as usual, I might have forgotten to add something there).

    - 3.0.7
    - Grid Graphs can now be scaled to allow non-square nodes, good for isometric games.
    - Added more options for custom links. For example individual nodes or connections can be either enabled or disabled. And penalty can be added to individual nodes
    - Placed the Scan keyboard shortcut code in a different place, hopefully it will work more often now
    - Disabled GUILayout in the AstarPath script for a possible small speed boost
    - Some debug variables (such as AstarPath::pathsCompleted) are now only updated if the ProfileAstar define is enabled
    - DynamicGridObstacle will now update nodes correctly when the object is destroyed
    - Unwalkable nodes no longer shows when Show Graphs is not toggled
    - Removed Path.multithreaded since it was not used
    - Removed Path.preCallback since it was obsolate
    - Added Pathfinding::XPath as a more customizable path
    - Added example of how to use MultiTargetPaths to the documentation as it was seriously lacking info on that area
    - The viewing mesh scaling for recast graphs is now correct also for the C# version
    - The StartEndModifier now changes the path length to 2 for correct applying if a path length of 1 was passed.
    - The progressbar is now removed even if an exception was thrown during scanning
    - Two new example scenes have been added, one for list graphs which includes sample links, and another one for recast graphs
    - Reverted back to manually setting the dark skin option, since it didn't work in all cases, however if a dark skin is detected, the user will be asked if he/she wants to enable the dark skin
    - Added gizmos for the AIFollow script which shows the current waypoint and a circle around it illustrating the distance required for it to be considered "reached".
    - The C# version of Recast does now use Character Radius instead of Erosion Radius (world units instead of voxels)
    - Fixed an IndexOutOfRange exception which could ocurr when saving a graph with no nodes to file
    - Known Bugs: The C++ version of Recast does not work on Windows

    The complete changelog can be viewed here
     
    Last edited: Oct 27, 2011
  6. Ambrosios

    Ambrosios

    Joined:
    Oct 22, 2011
    Posts:
    9
    I don't know why but my character doesn't avoid non-walkable area and get stuck in front natural wall.



    The red path is the current behaviour of stickman.
    The green path is what I want to achieve.

    Did I do something wrong ?

    EDIT : Some screenshot about my settings


     
    Last edited: Oct 27, 2011
  7. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    ...well probably, it shouldn't do like that. Can you turn on draw gizmos on the Seeker component and post a screenshot of the path that it has calculated?
     
  8. Ambrosios

    Ambrosios

    Joined:
    Oct 22, 2011
    Posts:
    9
    With Draw Gizmo enabled :



    and with Detailed Gizmo :

     
  9. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Okay. 1. It looks from the second image like you've got a hole in that wall.
    2. Looks like you are using the raycast modifier, but since that wall hasn't (?) got a collider, it will treat it as traversable.
     
  10. Ambrosios

    Ambrosios

    Joined:
    Oct 22, 2011
    Posts:
    9
    1.Okay, I fixed the hole in the wall and now the detailed gizmo shows me the correct path to take, but my stickman still go in the wall.
    2.I use the simple smooth modifier.

     
  11. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Ok, now that path looks correct, which script are you using for movement? (screenshot settings).
     
  12. Ambrosios

    Ambrosios

    Joined:
    Oct 22, 2011
    Posts:
    9
    I wrote my own PlayerController class with the following code for movement :

    Code (csharp):
    1.  
    2. void Update () {
    3.     if(Input.GetMouseButton(1)) {
    4.         Vector3 point = CameraScript.ScreenPointToTerrain();
    5.         if(point != Vector3.zero) {
    6.             seeker.StartPath(transform.position,point, debugPath);
    7.         }
    8.     }
    9.        
    10.     // ....
    11. }
    Code (csharp):
    1.  
    2. void FixedUpdate() {
    3.     if(path == null) {
    4.         return;
    5.     }
    6.        
    7.     if(currentWaypoint >= path.vectorPath.Length) {
    8.         return;
    9.     }
    10.        
    11.     Vector3 dir = (path.vectorPath[currentWaypoint]-transform.position).normalized;
    12.         dir *= speed * Time.fixedDeltaTime;
    13.        
    14.     LookAtDir(dir);
    15.         controller.SimpleMove(dir);
    16.  
    17.        
    18.         if (Vector3.Distance(transform.position,path.vectorPath[currentWaypoint]) < nextWaypointDistance) {
    19.             currentWaypoint++;
    20.             return;
    21.         }
    22. }
    Code (csharp):
    1.  
    2. public void debugPath(Path p) {
    3.     if(p.error) Debug.LogError("PathFinding error : " + p.errorLog);
    4.     else {
    5.         path = p;
    6.         currentWaypoint = 0;
    7.     }
    8. }
    And the settings :

     
  13. netics

    netics

    Joined:
    Aug 23, 2011
    Posts:
    102
    Goooood~. Thx.

    It improved.




    small problems.

    example scenes don't work.

    in fact, they didn't work at previous versions.

    when the Example3.scene start to play, the character just fall down from ground to hell.

    and warehouse structure is veeery small.

    Example4/5.scenes are same. falling to hell.
     
  14. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    I tried to update to 3.0 today but am having a particularly difficult time. I cannot seem to find replacements for the following:

    Code (csharp):
    1. AstarPath.active.SetNodesWorld(!add, mapRect, 0, false);
    Code (csharp):
    1. AstarPath.GetNode(x, 0, z).walkable;
    Basically the first one updates a rect on the grid to be not walkable, and the second just checks a grid space to see if it is walkable. Please advise on the replacement code, and maybe your website should be updated to include it in the upgrade notes. Thanks in advance.
     
  15. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Ayrik

    1. Check out this page in the docs:
    http://www.arongranberg.com/astar/docs/graph-updates.php

    2. You can replace that with
    Code (csharp):
    1. (AstarPath.active.GetNearest (myPosition).walkable;
    This will return the closest node to that position and check if it is walkable
    Function docs: http://www.arongranberg.com/astar/docs/class_astar_path.php#af02a97e86cb315ed64d8d0d6521b152f

    If you want to get a specific node index in a GridGraph you would have to do something like the following:
    Code (csharp):
    1.  
    2. GridGraph graph = AstarPath.active.astarData.graphs[0]; //Get the first graph, we assume it's a gridGraph.
    3. Node node = graph.nodes[y*graph.width + x]; //Where x and y are your coordinates... I think this is correct anyway.
    4.  
    It's a bit trickier to get a specific node index in a grid graph now since grid graphs are not explicitly hard coded into the system core.

    PS: I do actually have this on the upgrade page in the docs. Near the bottom I have the line
    "The syntax for graph updating has changed a bit, see Graph Updates during Runtime"

    @Netics
    That's really weird... the player character should have enough space between it and the ground to not just fall through the ground.
    Try to delete the whole AstarPathfindingProject folder from your project and import it again, that might solve it. It might be that the package does not override previous settings on import, unitypackages are a bit tricky.

    @Ambrosios
    Ok, now the path is correct, but it should debug a green line too (the Seeker) when you have Gizmos turned on, how does that look like. It should roughly follow the detailed gizmo path. Also, try to remove your modifiers and check if that solves it.
    Your script also looks correct from what I can see.
     
  16. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @BrUnO XaVIeR

    Do you have any specific feature request for list graph?
    If so, I would be glad if you posted them here, or commented on my Trello board here
     
  17. Ambrosios

    Ambrosios

    Joined:
    Oct 22, 2011
    Posts:
    9
    Problem resolved after removing the simple smooth modifier. I will try to change some parameters, maybe I did something wrong.
     
  18. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Ok... try to change the Max Segment Length variable to something smaller, that might help.
     
  19. d2king10

    d2king10

    Joined:
    Dec 21, 2009
    Posts:
    53
    I have a question, is there currently a function to use to see if the path is valid (walkable)? Basically we have an AI guy search for you by grabbing a random point in a circle around him and then navigating to that point, and I was wondering if there was a way to prevent him from grabbing a point via a function that is unwalkable?

    Thanks!
     
  20. netics

    netics

    Joined:
    Aug 23, 2011
    Posts:
    102
    I have a question.

    Is there any reason that GraphUpdateObject is managed by stack?

    Queue seems to be proper.
     
  21. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    I'd like them just to work lol.
    At least in my tests the list graph was hitting a out of index array all the time, I didn't mess with the code, just added the nodes to the list but it didnt work for all nodes, just a few ones, before firing out of index errors for the ones I did add latter.

    But I'm not using it anyways, Im using grids, so I can't give better feedback. I want to know too why the logs still firing while I set to fire just error logs.
    Maybe theres something I missed.
     
    Last edited: Nov 2, 2011
  22. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @BrUnO XaVIeR

    Thanks! I found the bug! I had forgot a ref statement in one of the functions so some nodes would get overridden by nodes found later.
    I have never got an IndexOutOfRange exception though... If you can find a reproducible case, I would be glad to see it.

    Oh, and I also found out why it fired messages even though it was set to error logs only. I had already set it to not print any text when only errors should be printed, but I had forgot to not log the empty string.

    These issues will be fixed in the next release.
     
  23. deepshit

    deepshit

    Joined:
    Jul 12, 2010
    Posts:
    9
    Hi
    I'm using A* project in my game.It works fine when enemies are less than 30 or 20 but when I spawn more than 50 enemies they kind of start dancing around target.
    They eventually get to target but they rotate around themselves when moving forward and as I said they do fine when enemies are less than 20.
    I tried to increase the Max Frame Time but it didn't work.
    Is there anything I should do?
    I'm using girdgraph.
    Thanks
     
  24. joel177

    joel177

    Joined:
    Oct 21, 2011
    Posts:
    42
    Thanks,that really helpfull!
     
  25. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @deepshit

    I'm not really sure why that would happen... I have tried it with over 500 units (though quite short paths, and using multithreading) pathfinding at the same time, and it has worked fine. Try increasing the Target Reached value on the AIFollow component (if you are using that).
    Just one thing, are they "dancing" around the final target point, or around points in the middle of the path? (if it's the second case, there is one case I know of which could cause that).
     
  26. deepshit

    deepshit

    Joined:
    Jul 12, 2010
    Posts:
    9
    Just around the final target point.
    I'm using a gridgraph with 250 width and 250 depth and the cell size is 1 and the free version so no multithreding.
    It's kinda like there's a delay in finding the target but repath rate is 0.
    they find the last spot the target was in and they spin around it until they find the new spot which is the spot the target was in 1 sec ago.
    If multithreading solves the problem I would buy the pro version.
     
  27. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    It sounds like it hasn't got enough time to calculate the paths. If you can, raise the Max Frame Time even more.
    Also, I wouldn't recommend a repath rate of 0 since it would seriously slow down the game, try 0.1 instead.
    The spinning is probably due to your Turn Speed on the AIFollow component is too low, so it will go around in circles around it, or the Target Reached value [0...1 range] value is too low (also, the Target Reached value depends on the Pick Next Waypoint Distance, so increasing that effects both).
    Multithreading would definitely solve the problem with slow repaths.
     
  28. deepshit

    deepshit

    Joined:
    Jul 12, 2010
    Posts:
    9
    I increased the Max Frame Time really much and it kinda worked.
    The other way that I tried was changing the cell size to 2.It worked too.
    I think I'm going to try the pro version too.
    Thank for your help.
     
  29. Aralox

    Aralox

    Joined:
    May 3, 2006
    Posts:
    12
    Hey there, your pathfinding package is really sweet, im loving it. Unfortunately ive also got the >60 000 verts error, and i know its a Unity bug, but i was wondering, is there was a way to suppress bugs in the unity editor?
    When gizmos are turned off during play it works fine, without the bug, so its something to do with displaying the grid.

    Thanks,
    Aralox
     
  30. hdswb

    hdswb

    Joined:
    Nov 3, 2011
    Posts:
    11
    hi, i am using your great tool to design a scene which is a building that has two different floors, i add two different layers for objects in two diffrent floors seperately and add two grids for different floors as well. when i run the game, everything is ok in the first floor with a grid in higher priority. but when the player go to the second floor, i notice that the player is always connected to the first floor grids not the second one, which results the player cannot avoid the obstacles in the second floor. what should i do if the player can follow the second floor's grid and avoid the obstacles in second floor? thank you for your help
     
  31. TehWut

    TehWut

    Joined:
    Jun 18, 2011
    Posts:
    1,577
    I would belive that the grid higher up would need a higher priority. Also, I'm not so sure about having more than one layer for obstacles is a good idea (but I'm not sure at all).
     
  32. hdswb

    hdswb

    Joined:
    Nov 3, 2011
    Posts:
    11
    well, i did try to use one grid for the first floor and all obstacles both on first floor and second floor with the same layer as well. what results i have go is that the obstacles on the second floor will project the unwalkable area to the first flloor, which means some parts of the first floor become unwalkable. that is the reason why i want to use two grids for two diffrent floor. however, unfortunately, when the player go to the second floor, it is always connected to the first floor grids not the second flloor's, which results the player cannot avoid the obstacles in the second floor. i just want to know if the player goes to the second floor, it can change to connect to the second floor's grid automatically. in that way , it can avoid the obstacles in second floor. how to set it to make this happen?
     
  33. xicidis

    xicidis

    Joined:
    Mar 2, 2010
    Posts:
    28
    Hey, great stuff! I have a quick question.

    I have a map with obstacles that can be placed in the way. I have them blocking the graph just fine, but I'm wondering what your suggestion on how I should do something. If the path is blocked, the unit will move as close as possible. Is there a way to tell if it has reached a node that it can't get to the next one from? I want to have them attack the wall in the way and try to break it down when they are unable to travel to the next node. Got any ideas?

    *Edit

    OK. One other small question that I can't seem to find in the docs.

    How do I make it stop looking for a new path? I set up a call to prevent it from moving if it's told not to, but that doesn't actually stop it from searching to make sure it's not going to path. Or, when it reaches the end of the point I tell it to, it keeps searching and searching. How do I stop this? I'm sure it's something silly that I'm overlooking, but it's killing my FPS.

    *Edit 2

    I'm using your AIFollow Script by the way. I've edited it quite a bit, but I was hoping you would have a quick fix to make it stop when it gets to its destination. =D
     
    Last edited: Nov 10, 2011
  34. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    I just downloaded the free version of this and brought it into a project.

    Right off the bat (I haven't touched anything yet) I get three errors that are preventing the system from even compiling.

    Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs(991,73): error CS0030: Cannot convert type `UnityEngine.Vector3' to `Int3'

    Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs(991,49): error CS1502: The best overloaded method match for `UnityEditor.EditorGUILayout.IntField(string, int, params UnityEngine.GUILayoutOption[])' has some invalid arguments

    Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs(991,49): error CS1503: Argument `#2' cannot convert `object' expression to type `int'


    Any ideas? I'm using Unity 3.4.2 Pro.
     
  35. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    What version of unity are you using?
     
  36. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Jak, most likely, you have another class named Int3 in your project, place that class in a namespace or change the name of it and everything should work fine.
     
  37. Ony

    Ony

    Joined:
    Apr 26, 2009
    Posts:
    1,977
    Ah, yep that was it. Thanks. :)

    Getting tired here and I should take a nap, haha.
     
  38. netics

    netics

    Joined:
    Aug 23, 2011
    Posts:
    102


    Red Line : the path expected

    Green Line : the path that I actually got

    Black Line : the path before modifier applied



    addtional info :

    I am using C# recast navmesh graph.
    and it only happens when the agent moves to upper region of the node(destination node in image)
    so I guess that node connectivity has no bugs but path cost calculation has the bug
     
    Last edited: Nov 14, 2011
  39. malcolmr

    malcolmr

    Joined:
    Feb 18, 2010
    Posts:
    51
    Is there any documentation on pathfinding with dynamic maps? I have a maze which lights up as the player explores it and I'd like to make sure that the pathfinder only searches the parts of the maze that are lit.
     
  40. kofboy

    kofboy

    Joined:
    Nov 6, 2009
    Posts:
    60
    Great work!

    But I can not figure it out how to use navmesh graph , does anyone has a tutorial talking about this ?


    Thanks.
     
  41. Erick

    Erick

    Joined:
    Mar 21, 2011
    Posts:
    14
    With 3.0.7 whenever i set the grid size to say like 100x100 and node size to like 5 unity crashes. I'm using unity 3.4.2
     
  42. Rook3D

    Rook3D

    Joined:
    Sep 27, 2011
    Posts:
    19
    Hello, I have a couple of questions:

    1) Does the Nav mesh generation Pathfinding cover proper vertical environments, ie: both a bridge the road underneath, multi-level buildings, tunnels under hill-tops?

    2) Is there the ability to use with very large environments, eg: a large 'Battlefield 2(3)' map, or even the 'Just Cause 2' map?

    Thanks.
     
  43. arkon

    arkon

    Joined:
    Jun 27, 2011
    Posts:
    1,122
    I've just downloaded what I thought was version 3.0.7 but when I import it into my game it says 3.0.6 in the about box, also the changelog stops at 3.0.6

    How can I verify I have the latest version? Also is there a direct email method to speak to the author?
     
  44. EskemaGames

    EskemaGames

    Joined:
    Jun 23, 2010
    Posts:
    319
    When will be the listgraph fixed for IOS?, I have the same issue as meanstreak (page 8). The root doesn't exists when you debug the messsage, but everything works as expected within the unity editor
     
  45. Lypheus

    Lypheus

    Joined:
    Apr 16, 2010
    Posts:
    664
    That was my experience as well, be nice to see this resolved as this is easily one of the better solutions for pathfinding out there imo.
     
  46. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    I encountered a new problem recently (using 3.08 and 3.5 Beta), which is when I build a game executable - the player crashes on startup. It's easily reproducable because it happens everytime: create a new empty project, import the pathfinding library, open the gridexample scene, build run. After playerstartup it crashes.
    Anyone else got this issue? Really strange thing, could be a fault of Unity Beta too, but it needs a fix :|
     
  47. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @marctro Thanks for the heads-up, working on it... (I have some #if UNITY_EDITOR somewhere in my scripts which is messing everything up, I have had the issue before, it usually causes Out-Of-Memory exception because variables get strange values and then I try to allocate space for the Binary Heap... which with random values for the length can easily be VERY large).

    @Eskema 3.0.8 uses a different way of serializing Unity references in the hope that it will work better for iPhone developers, try it out and tell me if it works.
     
    Last edited: Dec 24, 2011
  48. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Fixed, the only place where I though it was safe to have a #if UNITY_EDITOR statement was in a class I had by mistake exposed to the unity serializer, now I have removed those #ifs anyway so I won't make the same mistake again. The updated 3.0.8.1 version can be downloaded now (or at least in a few minutes when I have uploaded them completely), the asset store submission is pending.
     
  49. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
  50. rockysam888

    rockysam888

    Joined:
    Jul 28, 2009
    Posts:
    650
    (bookmarked)