Search Unity

A* Pathfinding 2.9 Is Released (Unity 3 Compatible)

Discussion in 'Assets and Asset Store' started by half_voxel, Nov 16, 2010.

  1. FernandoRibeiro

    FernandoRibeiro

    Joined:
    Sep 23, 2009
    Posts:
    1,362

    Hi there! =)
    Thanks for the answer!
    I'm trying to handle dynamic elements in my game, just like in a rts, and for now i'm using AstarPath.active.Scan(true,1);
    Is this the best method? Because most of the characters will be moving all the time. If so, what is the function of the second variable we use in the AstarPath.active.Scan, just after the "true" ?

    It would be better to use some kind of steering behavior instead of a* in dynamic elements? I'm trying to do it on iPad, so there are some stops each time AstarPath.active.Scan is called ( I usually call it once per second).

    Thanks for the attention!
     
  2. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    i try to make Tower Defence enemy AI . Enemy behave like RTS games. It decide how target closest me and change the target. However , i try to associate my javasacript code.Can it possible to associate with AIFollow.cs and my wayfinder.js

    Code (csharp):
    1.  
    2.  
    3. var target : Transform;
    4. var myPosition : Vector3;
    5. var enemies : Transform[];
    6.  
    7. var yuru:boolean=false;
    8.  
    9. var mesafe:float;
    10.  
    11. function Start ()
    12. {    
    13.     GetEnemies();    
    14.     myPosition = transform.position;    
    15.     target = FindClosest(enemies);
    16.     mesafe=Vector3.Distance(target.position,transform.position);
    17. }
    18.  
    19. function Update(){
    20.  
    21.      
    22.         if(Input.GetKeyDown(KeyCode.P)){
    23.        
    24.             yuru=!yuru;
    25.         }          
    26.        
    27.         if(yuru){   [COLOR="red"]//go to the target[/COLOR]
    28.                 GetEnemies();    
    29.                 myPosition = transform.position;    
    30.                 target = FindClosest(enemies);
    31.                 transform.LookAt(target.position);
    32.                 transform.Translate(new Vector3(0,0,.01));
    33.                 //enemies.RemoveAt(i);
    34.         //animation.CrossFade("walk");
    35.         }else{
    36.        
    37.             //animation.CrossFade("idle");
    38.         }
    39.  
    40. }
    41.  
    42. function GetEnemies () [COLOR="red"]//Get enemies[/COLOR]
    43. {    
    44.         var enemyObjects = GameObject.FindGameObjectsWithTag("enemy");    
    45.         enemies = new Transform[enemyObjects.Length];    
    46.  
    47.         for (i = 0; i < enemyObjects.Length; i++)
    48.         {          
    49.                 enemies[i] = enemyObjects[i].transform;    
    50.         }
    51. }
    52.  
    53. function FindClosest (targets : Transform[]) : Transform  [COLOR="red"]//Find closest enemy[/COLOR]
    54. {    
    55.  
    56.         var closestDistance = (enemies[0].position - myPosition).sqrMagnitude;    
    57.         var targetNumber = 0;    
    58.        
    59.         for (i = 1; i < targets.Length; i++)
    60.         {        
    61.                 var thisDistance = (enemies[i].position - myPosition).sqrMagnitude;        
    62.                 if (thisDistance < closestDistance)
    63.                 {            
    64.                                 closestDistance = thisDistance;            
    65.                                 targetNumber = i;        
    66.                 }    
    67.         }    
    68.     return enemies[targetNumber];
    69. }
    70.  
    71.  

    Here is my wayfinder.js . The robots AI should find the "enemy" and go near it. Then Fire() it. After destroying "enemy"

    robot get a new "enemy" automatically. Then looping them.

    Any help i will appriciate...
     
  3. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    i handled many things. My robots follow the target . However , when i add a robot (dublicated or cloning prefab) the fourth robot does not go to the target. And my robot prefab includes Seeker.cs , AIFollow.cs and wayfinder.js which is designed by me. Here is my code:

    Code (csharp):
    1.  
    2. var target : Transform;
    3. var myPosition : Vector3;
    4. var enemies : Transform[];
    5.  
    6.  
    7. var yuru:boolean=true;
    8.  
    9. var mesafe:float;
    10.  
    11. function Start ()
    12. {    
    13.    
    14.     GetEnemies();    
    15.     //myPosition = transform.position;    
    16.     target = FindClosest(enemies);
    17.     mesafe=Vector3.Distance(target.position,transform.position);
    18. }
    19.  
    20. function Update(){
    21.  
    22.     GetEnemies();
    23.     //myPosition=transform.position;
    24.     target=FindClosest(enemies);
    25.    
    26.     this.GetComponent("Seeker").StartPath(this.transform.position,target.position);
    27.    
    28.    
    29.  
    30. }
    31.  
    32. function GetEnemies ()
    33. {    
    34.         var enemyObjects = GameObject.FindGameObjectsWithTag("Target");    
    35.         enemies = new Transform[enemyObjects.Length];    
    36.  
    37.         for (i = 0; i < enemyObjects.Length; i++)
    38.         {          
    39.                 enemies[i] = enemyObjects[i].transform;    
    40.         }
    41. }
    42.  
    43. function FindClosest (targets : Transform[]) : Transform
    44. {    
    45.  
    46.         var closestDistance = (enemies[0].position - myPosition).sqrMagnitude;    
    47.         var targetNumber = 0;    
    48.        
    49.         for (i = 1; i < targets.Length; i++)
    50.         {        
    51.                 var thisDistance = (enemies[i].position - myPosition).sqrMagnitude;        
    52.                 if (thisDistance < closestDistance)
    53.                 {            
    54.                                 closestDistance = thisDistance;            
    55.                                 targetNumber = i;        
    56.                 }    
    57.         }    
    58.     return enemies[targetNumber];
    59. }
    60.  
    61.  
    62.  
    63.  
    64.  
    i do not understant. Why the fourth robot does not go its target. ? :confused:

    Any help i will appriciate...
     
  4. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    i handled it ... i change the Max Paths Per Frame at the Run Time Settings... This is the best moment of my life :)
     
  5. celadon

    celadon

    Joined:
    Oct 24, 2010
    Posts:
    16
    Thanks for providing this, it is an excellent resource! I have been playing with it on a test level, and have gotten it to work, but I have a question about the grid generation: There are paths between nodes that go directly through game objects with colliders. When a path is generated between these nodes, the characters just go up to the object and stop. I have played with as many of the settings as I can, and cannot get the grid to omit these connections.

    I am using Raycast for the y, and Capsule for the walkable check. The wall objects are in the Default layer (included in the walkable mask, not in the y mask). As you can see, most of the time there is no connection through the wall, but in certain areas there will be a connection every other node, and in other areas there are long stretches of unwalkable nodes along the wall...

    as you can see, the connection goes right through the collider, I even enlarged the collider to see if the path was going "over" or "under" the collider.



    Any suggestions?

    thanks
     
  6. celadon

    celadon

    Joined:
    Oct 24, 2010
    Posts:
    16
    Well, I have done some more testing and this appears to be related to node size - if the nodes are too big, sometimes one will "straddle" an angled obstacle and the grid generation script will sneak a connection across the corners? I did get rid of most of the errant links by reducing node size (from 5 to 2 or 2.5) but then I started getting the "audio hiccup" problem others have described.

    Not sure what will be a decent solution to this - it would be better if I could use the smaller nodes, since the current grid is really too coarse for my terrain, but the audio problems are not acceptable. At least knowing why this happens, I can tweak things to eliminate the the extra links (by making the colliders WIDER instead of taller, or sneaking a second collider in alongside the first where there is a problem).

    Happy New Year everyone!
     
  7. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @cemC

    Your first post: I haven't tested the whole code, but I can see one thing which will probably make it fail.
    In the Update function you have a line which calls Start() But in C#, when you want to call IEnumerators (Coroutines) you have to do like this

    Code (csharp):
    1. StartCoroutine (Start ());
    It wouldn't be a very good idea to do like that though, since the Start function will loop a piece of code an infinity number of times, if you run that function every frame it will quite soon bring any computer to halt.

    It would be better to make a new function called SearchForEnemies

    Code (csharp):
    1. public IEnumerator SearchForEnemies () {
    2.     while (true) {
    3.         //here is the start array operations
    4.         GetEnemies();    
    5.         myPosition = transform.position;    
    6.         target = FindClosest(enemies);
    7.         distance=Vector3.Distance(target.position,transform.position);
    8.        
    9.         //Search for a new enemy every 0.1 seconds
    10.         yield return new WaitForSeconds (0.1F);
    11.     }
    12. }
    And call that function from Start

    Code (csharp):
    1. //In the start function
    2. StartCoroutine (SearchForEnemies ());
    Also remove the Start (); from Update ();


    Take a look at this page for info on javascript (the "Important" paragraph at the top):
    http://www.arongranberg.com/unity/a-pathfinding/docs/othercode/

    @Celadon

    You can increase the node radius (in the grid's physics settings) to 1.4142 (square root of 2), to make the collision check cover exactly everything the node touches. Also you can turn on the Don't Cut Corners toggle.
     
  8. celadon

    celadon

    Joined:
    Oct 24, 2010
    Posts:
    16
    Thanks Aron, I just tried your suggestions, and while they do eliminate the extra links, they also eliminate too many of the needed links.

    However, it looks like I can reduce the node size to 4 without getting audio hiccups, and I can probably use the node disabler to ditch the few remaining bad links, right? I will have some fairly cramped roads and other restricted terrain areas, and I don't want to have to open them up wider just to enable the pathfinding. I am still not sure exactly how big my terrains will be for the final game (still in early testing) - so I may be able to make smaller terrains with denser navmeshes...
     
  9. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    Hi, i tried using the list method to generate my paths, however, when trying to find the path something strange happens.



    With reference to the picture, the NPC first moves all the way to the top then follows the pink path to the destination. there are path nodes path right at its starting point as can be seen by the green line yet it moves right to the top :(

    Update 1 :
    Just tested with other starting positions and destinations... some paths are ok, but for many the path cuts a straight line through vast areas instead of following the path i hoped it would follow.

    Update 2 :
    In debug mode, i see that the start pos is correct, but element 1 is the node at the top. Will look more in the code to see how the point was chosen. The start pos is about ( 187, 0, -545 ) the nearer nodes should be at (185, 0.1, -568 ) and the points along the upper part which it goes to as seen by the blue line have co-ordinates of about (265, 1.7, 897). Under runtime setting's I have already selected "World Positions" for H calculation.
     
    Last edited: Jan 7, 2011
  10. ChaosWWW

    ChaosWWW

    Joined:
    Nov 25, 2009
    Posts:
    470
    Hey, I'm wondering if anybody has a link to the older Unity 2.6 compatible version? Thanks.
     
  11. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    I'm using it with 2.6, so yes, its compatible.
     
  12. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    Problem solved, by setting the forcenodesunder flag to false in tolocaltest. Are there any consequences of doing this ?

    Also, another question. Is there anyway to use multilpe grids when using list mode ? This will enable me to make a tighter grid with in the building and a more spread out grid in the outside environment.
     
    Last edited: Jan 11, 2011
  13. celadon

    celadon

    Joined:
    Oct 24, 2010
    Posts:
    16
    Is there an appropriate place to discuss more advanced pathfinding concepts (e.g. pathfinding around locked doors, group movements, etc.) with your script? I don't want to sidetrack this thread since it is focused on issues with the 2.9 release.
     
  14. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Celadon

    Not at the time no. Feel free to start one though! :D
     
  15. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    i have a problem about the Seeker.cs script. i write a javascript code for Enemy Orb. And Also i use the AIFollow.cs on my orb.

    Here is te code:

    Code (csharp):
    1.  
    2.  
    3. var target : Transform;
    4. var myPosition : Vector3;
    5. var enemies : Transform[];
    6. var counterHit : int;
    7.  
    8.  
    9.  
    10. var damping = 6.0;
    11.  
    12. function Start ()
    13. {    
    14.     counterHit=0;
    15.     GetEnemies();    
    16.     myPosition = transform.position;    
    17.     target = FindClosest(enemies);
    18.    
    19. }
    20.  
    21. function Update(){
    22.  
    23.     this.transform.position.y=20;
    24.    
    25.     GetEnemies();
    26.     myPosition=transform.position;
    27.     target=FindClosest(enemies);
    28.    
    29.     this.GetComponent("Seeker").StartPath(this.transform.position,target.position); //Use The Seeker.
    30.    
    31.     var rotation = Quaternion.LookRotation(target.position - transform.position);
    32.     transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
    33.    
    34.    
    35. }
    36.  
    37.  
    38.  
    39. function GetEnemies ()
    40. {    
    41.         var enemyObjects = GameObject.FindGameObjectsWithTag("Target");    
    42.         enemies = new Transform[enemyObjects.Length];    
    43.  
    44.         for (i = 0; i < enemyObjects.Length; i++)
    45.         {          
    46.                 enemies[i] = enemyObjects[i].transform;    
    47.         }
    48. }
    49.  
    50. function FindClosest (targets : Transform[]) : Transform
    51. {    
    52.  
    53.         var closestDistance = (enemies[0].position - myPosition).sqrMagnitude;    
    54.         var targetNumber = 0;    
    55.        
    56.         for (i = 1; i < targets.Length; i++)
    57.         {        
    58.                 var thisDistance = (enemies[i].position - myPosition).sqrMagnitude;        
    59.                 if (thisDistance < closestDistance)
    60.                 {            
    61.                                 closestDistance = thisDistance;            
    62.                                 targetNumber = i;        
    63.                 }    
    64.         }    
    65.     return enemies[targetNumber];
    66. }
    67.  
    68.  
    69.  
    70.  
    71.  
    72.  
    i put the drone more than 10 (and there are 10 EmptyGameobject in the scene, they make clone of orb when the Orbs are destroyed) . During cloning of the Orbs , Orbs do not move anywhere. And they do not work...

    In my A* object here is the Advanced Values:

    Heap Size : 0.5;

    Path Queue Size : 5000;

    Here is first error

    Code (csharp):
    1.  
    2.  
    3. [COLOR="red"]MissingReferenceException: The object of type 'Seeker' has been destroyed but you are still trying to access it.[/COLOR]
    4. Your script should either check if it is null or you should not destroy the object.
    5. Seeker.OnComplete (.Path p) (at Assets/AstarAI/Standard Assets/Pathfinding/Seeker.cs:182)
    6. AstarPath+<CalculatePaths>c__Iterator4.MoveNext () (at Assets/AstarAI/Standard Assets/Pathfinding/AstarPath.cs:557)
    7.  
    8.  

    There is another error after The first error is showed :

    Code (csharp):
    1.  
    2.  
    3. [COLOR="red"]To Many Paths In Queue, please increase queue size or call StartPath less often[/COLOR]
    4. UnityEngine.Debug:LogError(Object)
    5. AstarPath:StartPath(Path) (at Assets/AstarAI/Standard Assets/Pathfinding/AstarPath.cs:490)
    6. Seeker:StartPath(Vector3, Vector3) (at Assets/AstarAI/Standard Assets/Pathfinding/Seeker.cs:270)
    7. Seeker:Seeker$StartPath$UnityEngine.Vector3$UnityEngine.Vector3(Object, Object[])
    8. UnityScript.Lang.UnityRuntimeServices:Invoke(Object, String, Object[], Type)
    9. WorkerWayFinder:LateUpdate() (at Assets/Scripts/WorkerOrb/WorkerWayFinder.js:48)
    10.  
    11.  
    12.  
    How can i fixed the problem ? :(

    There are some screenshots from my project...

    Any Help i will appriciate....
     

    Attached Files:

    Last edited: Jan 19, 2011
  16. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    i handled it. :)

    Here is my code:


    Code (csharp):
    1.  
    2. var target : Transform;
    3. var myPosition : Vector3;
    4. var enemies : Transform[];
    5.  
    6.  
    7.  
    8.  
    9. var damping = 6.0;
    10.  
    11. function Start ()
    12. {    
    13.     GetEnemies();    
    14.     myPosition = transform.position;    
    15.     target = FindClosest(enemies);
    16.    
    17.    
    18.     this.GetComponent("Seeker").StartPath(this.transform.position,target.position);//for start
    19.  
    20. }
    21.  
    22. function Update(){
    23.  
    24.    
    25.     this.transform.position.y=20;
    26.     if(!target){ // controll the StartPath()
    27.     GetEnemies();
    28.     myPosition=transform.position;
    29.     target=FindClosest(enemies);
    30.    
    31.     this.GetComponent("Seeker").StartPath(this.transform.position,target.position);
    32.    
    33.     }
    34.    
    35.  
    36.     var rotation = Quaternion.LookRotation(target.position - transform.position);
    37.     transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
    38.    
    39.  
    40.  
    41. }
    42.  
    43.  
    44.  
    45.  
    46. function GetEnemies ()
    47. {    
    48.         var enemyObjects = GameObject.FindGameObjectsWithTag("Target");    
    49.         enemies = new Transform[enemyObjects.Length];    
    50.  
    51.         for (i = 0; i < enemyObjects.Length; i++)
    52.         {          
    53.                 enemies[i] = enemyObjects[i].transform;    
    54.         }
    55. }
    56.  
    57. function FindClosest (targets : Transform[]) : Transform
    58. {    
    59.  
    60.         var closestDistance = (enemies[0].position - myPosition).sqrMagnitude;    
    61.         var targetNumber = 0;    
    62.        
    63.         for (i = 1; i < targets.Length; i++)
    64.         {        
    65.                 var thisDistance = (enemies[i].position - myPosition).sqrMagnitude;        
    66.                 if (thisDistance < closestDistance)
    67.                 {            
    68.                                 closestDistance = thisDistance;            
    69.                                 targetNumber = i;        
    70.                 }    
    71.         }    
    72.     return enemies[targetNumber];
    73. }
    74.  
    75.  
    76.  
    77.  
    78.  
     
  17. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    I found a bug in Seeker.cs in OnComplete with this line:
    Code (csharp):
    1. if (startPoint == RealStart.Exact  !path.forceStartSnap) {
    2.     a[0] = startpos;
    3. }
    It needs the !removeFirst check I have added below:
    Code (csharp):
    1. if (startPoint == RealStart.Exact  !path.forceStartSnap  !removeFirst) {
    2.     a[0] = startpos;
    3. }
    This is because if path.forceEndSnap is set, but path.forceStartSnap is not, it will never replace a[0] with endpos, resulting in a[0] as your one and only node, and is set to startpos...
     
  18. cospace

    cospace

    Joined:
    Oct 5, 2010
    Posts:
    7
    Just wondering, is there anyway to save the grid and just reload it on start instead of scanning on start ?
     
  19. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Cospace

    Currently no, I have done some testing with it (hence the AstarData component which has been in the project for a few versions), but it's quite hard to serialize it.

    @Ayrik, ok, I will take a look at that.
     
  20. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Hi everyone

    I just wanted to tell you that I have released a new version of the system, 2.93.
    It's a bugfix release, some of the bugs fixed are, for example when reloading a scene, the pathfinding would sometimes not work, and also if the object which sent the pathfinding request was destroyed, it won't cause a NullReferenceException anymore.

    Download it here: http://www.arongranberg.com/unity/a-pathfinding/
     
  21. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    Hello Sturestone.
    Has i told in previous posts i can't get to work the new version (with the old one and unity 2.6 all worked well).
    I'm talking of a mesh path.
    You told me that the problem was that there was too many tringles connected between each other. Now i fixed the mesh (it's attached) but when i try to generate a route the pathfinder tell me that

    "Start Point : No nearby Nodes Were found (Position not inside any grids or no nodes were close enough"

    the char controller is near a node (as u can see from the screenshot).

    Where is the problem?

    Thank you.
     

    Attached Files:

  22. pakfront

    pakfront

    Joined:
    Oct 6, 2010
    Posts:
    551
    Haven't tried the update yet as I had to modify (based on you advice here) the Scan() method to get my own penalty system working. I'm sure reintegrating it will only take a moment, though.

    Any chance you could implement a callback for user's custom penalty calculation methods? Currently I have this:

    Code (csharp):
    1.                                
    2. for (int x=0;x<grid.width;x++) {//Width
    3.     ...
    4.     node.vectorPos = new Vector3 (((float)x+0.5F)*grid.nodeSize+grid.offset.x,grid.offset.y,((float)z+0.5F)*grid.nodeSize+grid.offset.z);
    5.  
    6.    //added by pakfront
    7.    node.penalty = SimManager.GetLocationWeight(node.vectorPos);
    8.  
    9.     FullPhysicsCheck (node,grid,0);
    10.    ...
    11.  
    12.  
    If you were to get a callback working, I suggest that args be position and grid name or index so that the user can assign different penalties based on which grid is being calculated (I plan on using one grid for foot units and another for vehicles)

    Thanks for a great system so far!
     
    Last edited: Jan 30, 2011
  23. cyangamer

    cyangamer

    Joined:
    Feb 17, 2010
    Posts:
    234
    Hi, Aron. Thanks so much for this package.

    It seems there's an issue with your latest release. Every time I click on the Game Object containing the A* script, I get a message telling me that the AstarSkin asset is damaged and I need to redownload. The script won't work at all. The issue comes from the fact that I imported the package directly from your site. I'm thinking you need to just replace the AstarSkin with another one.

    In the meantime, I'll just copy the files from the example project over to mine. The example project seemed to have worked.

    EDIT: Actually, it seems that the unitypackage does work -- in every project except mine. I guess one of my scripts is setting off flags in one of your scripts and making them think there's nothing wrong with the AstarSkin.

    EDIT2: Fixed it. For some reason, my project couldn't match the Texture2Ds used in the styles of the AstarSkin with the Texture2Ds sitting in the Assets, so I had to manually drag and drop them. Now it works!
     
    Last edited: Feb 5, 2011
  24. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Goldrake

    Either try to increase the Bounding box extension so you are sure the start point is inside the white bounding box.

    Or otherwise make sure the point is above a triangle (the start point needs to be above the triangle, not under), and that it is inside a triangle when you look at the point in top-down view.

    @Pakfront

    That's under development, I'm currently developing version 3.0 which will have support for custom graph modifiers (which could for example, modify the penalty).
     
  25. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    Sorry, i can't get it work well. If i use "use position: center" the error of starting point will not show but the next node is incorrect. But if i move the controller and in another part of the path and recall the StartPath it tells me again that the start point is not in the grid.

    If i use "use position: edge" i have again the error of Start point. The start and the target are both in the grid and inside a triangle (above).

    What i can do?
    I'm tring to solve this problem since a month. I think there is some bug. Have you tried the mesh i attached?

    Thank you
     
    Last edited: Feb 5, 2011
  26. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
  27. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    Hello sturestone,
    sorry but didn't you see my last post?

    Thank you
     
  28. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Hi Goldrake

    Yeah, I should have written something, I didn't have time then to answer your post, but I will do it now.

    I tried the mesh, but I couldn't find any errors, my seeker finds the correct path all the time.
    I used Edge mode, with a large "Bounds Margin", the start point is inside a triangle (top-down) and above it, the target point as well.

    I'm not really sure what to do, I can't reproduce your error, try to set everything up (at least the pathfinding) from scratch in a new scene, that might help.

    Oh, and btw: you haven't accidentally set the Grid Selection variable on the Seeker to something other than "Auto"?
     
  29. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
  30. Sollthar

    Sollthar

    Joined:
    Feb 11, 2010
    Posts:
    486
    Nice! Just downloaded it and got about 5 compiler errors - I guess that's why then. :)

    Thank you very much for your fantastic work!
     
  31. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Now the fix is available for download.
    With 2.94, the A* Pathfinding Project is compatible with Unity 3.2!

    Download it here

    -Aron
     
  32. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Hi Everyone

    I have a demo for you from the A* Pathfinding Project version 3.0.
    This is a multithreaded demo in a 218*187 grid.
    It will just display the shortest path from the start with some smoothing applied.
    Another thing that is new is that I am using euclidean distance (real distance) instead of the manhattan distance, this makes the path look better.

    I would be interested in hearing what performance you get (measure it when placing the target on the yellow dot)
    And windows users, beware, this webplayer might crash your browser!
    But I have tried to avoid any contact with the Unity API, no Unity functions, not even math functions are called from the other thread... Now just let's hope it works.

    Here's the link to the webplayer: http://arongranberg.com/wp-content/uploads/astarpathfinding/demos/multithreded.html
     
    Last edited: Feb 16, 2011
  33. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    Hello Aron,
    I've just test it out (your 3.0 version).
    Works well, no crash (I'm using windows XP 32bits) right now.
    If the path length is below 210 i got between 0 and 15ms computation time,
    If the path length is larger than 210 (near the yellow target and beyond it) computation time takes between 15 and 30ms.
    Btw, when v3.0 will be public released? Any beta/RC date? :D
    Keep it on, its looking good.
     
  34. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    No crash on windows! YES!!! :D

    No ETA yet, I have only worked on it for about a month, and it's still a LOT to do. I'm rewriting the whole project, you see.
     
  35. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    Awesome,
    I'm keeping an eye on this tread anyway, if you want some feedback and test, make sure to update it asap when you got something. :D
    Cheers,
     
  36. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    Path length = 324
    calculation time = 15.625ms
    using windows xp sp3

    Can you give a simple example of how to write my own AIfollower script. I am lost at how to calculate the path and follow it.

    Also, about the AstarData thing. Can we save the grid and load it without calculating everytime?
     
  37. Vinícius Sanctus

    Vinícius Sanctus

    Joined:
    Dec 14, 2009
    Posts:
    282
    Im totally using this later on HoH! How does the using license works? Thx!
     
  38. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    No Crash on macos snow leopard and safari.

    Sturestone about the mesh path with node edged: i can't get it work also with a new project ( i tried really everything). As i told you if i use the node center it works. (I'm using iphone project unity3.2, probably that is the problem?)

    Another big question. I'd like to save the data path and not to scan it at startup. On iphone it takes too much. Is it possible? How?

    Thank you very much
     
  39. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Great!

    It seems to work for everyone so far (anyone got vista or windows 7 and wants to test it?)

    @Goldrake
    Hmm... do you think you can pm me a project where you are getting the bug?

    I have tried to make saving possible, but I haven't succeeded yet (to make it work in a good way), AstarData is a left over trace from that.
    With version 3.0 I will try to make it work again.
     
  40. Ayrik

    Ayrik

    Joined:
    Aug 31, 2008
    Posts:
    430
    Works fine for me in Windows 7 64-bit
     
  41. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    1) I'm zipping it and i'll upload to let you download.

    2) version 3.0 tested on vista and it works well
     
  42. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Version 3.0 is progressing, today I managed to implement a multi level grid which a lot of people have been asking for. It is based on my not finnished ala Recast code, as that code already uses such a representation internally.
    As a test, I made it compute a multi level grid from all triangles in the scene which you can see in the webplayer I posted before (plus some other stuff to make it more multi level), it worked really well, all done in 0.2 seconds (I think that is faster than to compute a standard grid in the current version (2.9x))! :D

    I haven't got any pictures now, but I will post some on Tuesday I think.

    PS: Perfect Goldrake
     
  43. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    As seen in the attached photo, yellow and green zones are unnecessary. What is the easiest way to remove those?

    Also, what would be the most efficient way of putting waypoints instead of a node grid in such a T shape?
     

    Attached Files:

    • $1.jpg
      $1.jpg
      File size:
      62 KB
      Views:
      991
  44. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    Awesome Aron,
    Can't wait for the 3.0 :)
    I'm having a bunch of nullreference exceptions using waypoints lists in v2.94.
    For example, if a seeker goes below a waypoint position (Y value), AstartPath throws a bunch nullref errors.
    Also, try to make all of its existing 2.94 features works. None of them except List works for me.
    Keep the hard work, :)
    Cheers,
     
  45. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    Ok, here are some screenshots from the Multi layer graph generator

    @Aubergine

    There is no way to remove those currently. If you worry about memory I wouldn't worry at all with that small grid size.

    @Tatoforever
    I will take a look at the problems you are describing. Also, can you elaborate a bit on "how" it doesn't work for you (do you get a lot of errors (if so, which?), or is it simply not working in the scene, or something else?
     

    Attached Files:

    Last edited: Feb 23, 2011
  46. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,366
    The issue is only visible if my seeker's character controller is below the lowest waypoint in the scene.
    I'll post some screenshots later, but here are the repro steps:
    - Add few waypoints to the scene.
    - Make them a child of a parent gameObject.
    - Make sure all the waypoints have the same Y position and are above the ground/floor level collider.
    - In your Astar Path component, Change your method to "List" inside Static Settings and add the waypoint's parent to the Root Node field.
    - Add a gravity function to your AIFollow or to whatever script you are using to move your seeker. (This may provably be the issue, to my understanding, your waypoint system was made with the idea of no gravity at all, as getting below the lowest waypoint makes those null ref exceptions I've explained earlier).

    I'm reproducing the issue and post few images soon.
    Cheers,
     
    Last edited: Feb 23, 2011
  47. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    The Multi layer graph generator looks awesome!!

    When do you think that this will be available?????
     
  48. ChrisPaulson

    ChrisPaulson

    Joined:
    Nov 16, 2010
    Posts:
    43
    Interesting to see your now doing this - I'm currently working on my own version of this. It's a little slow going for me though as I am new to Unity and C#.

    Have you developed a rasterize triangle algorithm?
     
  49. half_voxel

    half_voxel

    Joined:
    Oct 20, 2007
    Posts:
    978
    @Reset

    Thanks, but there is not ETA right now.

    @ChrisPaulson
    Yes I have developed a rasterize triangle algorithm... or well, I tried at first, but then I realized that converting Recast's algorithm was much faster, and it was more robust than mine.
     
  50. ChrisPaulson

    ChrisPaulson

    Joined:
    Nov 16, 2010
    Posts:
    43
    I was going to to do a conversion of the recast algorithm too, but I need to find the time which is difficult when there's so much to do. The code is quite hard to understand and I not sure how clip poly works. For now I rely on physics.checkcapsule which I think is not so fast.

    I'll be posting my WIP first cut of my code soon so you can pick faults.