Search Unity

SimplePath - Advanced Pathfinding for any Game Genre - RELEASED

Discussion in 'Assets and Asset Store' started by alexkring, May 18, 2011.

  1. AtomicMarine

    AtomicMarine

    Joined:
    Nov 7, 2010
    Posts:
    53
    So I have a randomly generated dungeon with many enemies in play, up to hundreds. I only want them to path find when the player gets near to them.

    I did this buy activating and deactivating the Interaction_Chase class when the player gets near or far. Only issue now is that when I hit a huge dungeon I get an error saying that i've hit the maximum amount of nodes per planner and should increase this number despite the fact that it's about 1000 and all the enemies actually finding paths are far to far away from the player to get agro-ed by him. Also I've tried activating and deactivating the steering component, which didn't work.
     
  2. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    You could do this. I think steering and collision response code is often an experimemental combination of hacks that are specific to your game. Just keep in mind how SimplePath considers steering and collision response. Pathfinding, Steering, and Collision Response are all seperate systems that can world independently. SimplePath doesn't have any sort of notion of collision response, because that sort of code is usually custom for each game; also, many games don't need collision response code, which is why SimplePath just has pathfinding and steering.

    Anyway, if you want to add custom steering and collision response code, I would either replace the SteeringComponent with your code, or add a CollisionResponseComponent that works with both the pathfinding and steering components. The NavigationComponent is sort of the high level orchestrator of all of these components.

    To see how these systems are independent, take a look at the SteeringComponent, and look at how it consumes path information. Basically it just takes in a list of points, which is the path, and then it determines how to steer the agent along the path. In other words, the input is a list of points from the pathfinding system, and the output is a velocity which gets applied to the agent.
     
  3. wmaass88

    wmaass88

    Joined:
    Dec 23, 2012
    Posts:
    45
    Hello,

    I am looking at getting this to solve a problem I have. I need a way to dynamically measure and show the user the distance to a point based on their current position, taking into considerations walls and other obstacles. Would this be possible with SimplePath?
     
  4. Zozo2099

    Zozo2099

    Joined:
    Jul 15, 2012
    Posts:
    478
    Please can someone tell me if it works with Unity 4? thanks
     
  5. code-blep

    code-blep

    Joined:
    Oct 1, 2010
    Posts:
    308
    Hi Zozo2099: Yep it works great in Unity 4 :)
     
  6. Rukey4

    Rukey4

    Joined:
    Sep 23, 2012
    Posts:
    73
    Hello,

    Not sure if this was covered in the documentation or I just missed out. I have my own agrent (Enemy character) in game using both Agent_Wander or with the waypoints. The problem I have, is there a way to get the agent to look in the correct direction when walking? As it seems to be locked on every axis and moves frozen as such.

    Thanks.
     
  7. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Yes. You can plan a path from the user to the destination, just don't use the SteeringComponent to physically move the user. When the path is solved, you can look at the length of the path (the data structure for the path stores this distance).
     
  8. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    I posted some steering code to do this several posts back. Let me know if you have trouble finding this post.
     
  9. TCE

    TCE

    Joined:
    Dec 5, 2012
    Posts:
    4
    hello,
    if ihave "point a " and "point b" in my map,i have enemy at "point a" and i want to move enemy to "point b" by simplepath ,but i dont want enemy to patrol from a to b. How i can disable patrol mode? :confused:


    Thanks
     
  10. TCE

    TCE

    Joined:
    Dec 5, 2012
    Posts:
    4
    i read simplepath code carefully in 3 days, i understand how to make it now ,very happy :)
     
  11. x_ming_x

    x_ming_x

    Joined:
    Jan 1, 2013
    Posts:
    46
    Hello Alex

    ive had simple path for a while now and have it working nicely in my project, but i recently bought a copy of the modelling addon "Gamedraw" and when installed im getting lots of errors in the footprint component, ive tested it on a blank project and if both gamedraw and simplepath are installed it cant compile, heres the errors

    Assets/SimplePath/Main/Code/AI/Components/FootprintComponent.cs(47,72): error CS1061: Type `Grid' does not contain a definition for `Origin' and no extension method `Origin' of type `Grid' could be found (are you missing a using directive or an assembly reference?)

    Assets/SimplePath/Main/Code/AI/Components/FootprintComponent.cs(47,96): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Vector3(float, float, float)' has some invalid arguments

    Assets/SimplePath/Main/Code/AI/Components/FootprintComponent.cs(47,96): error CS1503: Argument `#2' cannot convert `object' expression to type `float'

    ....... and they go on it seems to be having problems with the "grid" as all of the errors mention that

    as the errors are coming up in the simplepath scripts im hoping i can fix it with some script edits

    any help would be much appreciated as i really like both addons and im kinda stuck with this conflict
     
    Last edited: Jan 12, 2013
  12. MornFall

    MornFall

    Joined:
    Jan 11, 2013
    Posts:
    160
    Hi Alex,

    I just purchased Simplepath, and i somehow managed to set it up properly with my little project. I only have 2 weeks of programming in my head so please pardon my nuubish style.
    Here is my question :

    I have several cubes on my map. When i click on one of them, it gets selected ( By raycast ).
    Now, i am trying to make an agent go to this cube. ( I only know Java script so far ).

    Here is what i tried:

    Code (csharp):
    1. if(Input.GetButtonDown("Mouse0")) {
    2.             var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    3.             var hit : RaycastHit;
    4.             if (Physics.Raycast (ray, hit, 1000, blockLayer)) {
    5.                 selectedBlockHit = hit.collider.gameObject;
    6.                 if (selectedBlockHit.tag=="BlockEmpty"){
    7.                     workerT1.Interaction_Chase.chaseObject = selectedBlockHit   ;
    8.                     selectedBlockHit.SendMessage("SelectedByTeam1");}
    9.  
    I know that the SendMessage works, so the cube is being hit and selected.
    My workerT1 is my agent, and i am trying to send him to the cube ... but for some reasons, i get that in the console, when i click on the cube :
    " NullReferenceExeption : Object reference not set to an instance of an object. Boo.Lang.RuntimeServices. ect ectect.. "

    I am not even sure i am sending the variable properly, or if it is even possible to send a variable from a unityscript to a C# script...
    All i know : My workerT1 is properly assigned, and it has all the components for an agent to work. It is working if i manually change chaseObject variable the cube in the editor

    Any help would be much appreciated, thanks.


    EDIT : Actually, changing a few things made it work ! Let's move on !

    I replaced " workerT1.Interaction_Chase.chaseObject = selectedBlockHit ; "
    by
    var cSharpScript = workerT1.GetComponent("Interaction_Chase");
    cSharpScript.m_chaseObject = selectedBlockHit ;
     
    Last edited: Jan 19, 2013
  13. MornFall

    MornFall

    Joined:
    Jan 11, 2013
    Posts:
    160
    EDIT : Nevermind again, that was me doing wrong.
     
    Last edited: Jan 19, 2013
  14. GC1983

    GC1983

    Joined:
    Jan 23, 2012
    Posts:
    22
    Hey Alex,

    Im trying to create more of an arc/circle path with the pathfinding system. My issue is that its very jerky. Im using LookRotation() to face the object and often the path makes the object jerk when it reaches the path node. Is there a way to make it look more fluid when creating a more rounded like path?

    Thanks!
     
  15. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Make sure you place SimplePath in the Assets/Plugins/ folder. Try creating a new project, and doing this first, to be sure that it works.
     
  16. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Try lowering the acceleration rate on the steering agent component. Or are you referring to a jerk in the turning, as opposed to a jerk in the translation?
     
  17. MornFall

    MornFall

    Joined:
    Jan 11, 2013
    Posts:
    160
    Could that be a glitch or me doing something wrong ?



    Basically... My little agent is supposed to go to any block that i select, and destroy them.
    Thing is... as you can see on the image, it is really not taking the shortest path. That does not occurs all the time, which makes it ever weirder....

    Here is when it works



    This is the part of the code that calls the Move on the agent :
    Code (csharp):
    1. function FindBlock (){
    2.     nearestDistanceSqr  = Mathf.Infinity;
    3.     nearestBlock        = null;
    4.     for (var block : GameObject in GameManager.blockSelectedT1){
    5.         blockPos = block.transform.position;
    6.         var distanceSqr = (blockPos - Vector3(transform.position.x, blockPos.y, transform.position.z)).sqrMagnitude;
    7.         if (distanceSqr < nearestDistanceSqr){
    8.             nearestBlock = block.gameObject;
    9.             nearestDistanceSqr = distanceSqr;
    10.         }
    11.     }
    12.     targetBlock     = nearestBlock;
    13.     targetBlockPos  = nearestBlock.transform.position;
    14.     navScript.SendMessage("MoveToPosition",targetBlockPos);
    15. }
    The center of the block is well put in the middle of it.

    PS :
    I followed the post Alex made on this thread to replace the "replanInterval" by float.mathinfinity.
    navScript being the NavigationAgentComponent.

    Another example :


    It can dig all the way up to the last block.. then for some reason it needs to go back up and destroy it from the other side... what.. the... heck...
     
    Last edited: Jan 25, 2013
  18. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    It looks like you have path smoothing turned off, which is the cause of the jagged looking path that you are seeing. On the NavigationAgentComponent, within the Unity inspector, make sure the "Use Path Smoothing" box is checked. You can dynamically turn this on and off to see how it affects the paths.
     
  19. lenny.myr

    lenny.myr

    Joined:
    Jul 13, 2012
    Posts:
    5
    When I order my character to go somewhere, where he can't go to, e.g. onto an obstacle, I still want him to go as close to this point, as he can get.
    How would you do this?
     
  20. MornFall

    MornFall

    Joined:
    Jan 11, 2013
    Posts:
    160
    No Alex, i am not talking about the path. i am not sure you have read what i wrote properly or i am not clear enough, but i would not know how to say it differently.
    If you look at the last picture, the white sphere is in front of the yellow block, but it still try to go on the other side completly to get to it. it works well from all the other ways, it only happens when the agent is " south" i guess, from the block.
    The path that you see on the picture is the agent who "destroyed" the blocks, until the very last block ( that is in yellow ). For some reasons, for the this last block, the agent wants to go all the way back, on the other side of the block. I am really not sure what is causing that.
     
  21. lenny.myr

    lenny.myr

    Joined:
    Jul 13, 2012
    Posts:
    5
    Hey alex, I'd like to know, whether it is possible to use "portals" which teleport the character to another point in your Pathfinding?
    Also I'd like to know, whether it is possible to let my character go the DIRECT way to a waypoint?

    Thanks and bye for now

    EDIT: Or better: Is it possible to generate a path and save the waypoints in a Vector3[] ?
     
    Last edited: Jan 30, 2013
  22. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Yes, you can generate the path and save it in a Vector3 of waypoints. Actually, this Vector3[] array is already generated for you.

    Take a look at the "OnPathRequestSucceeded" message that is sent by the PathAgentComponent. This is sent whenever the path is solved, and it contains the list that you are looking for. If you don't want the agent to follow that path, simply don't have the steering system respond to this message. Look at the OnPathRequestSucceeded function in NavigationAgentComponent. This is where the list is passed to the steering system, and the agent begins following the path.
     
  23. Xinity

    Xinity

    Joined:
    Oct 10, 2012
    Posts:
    5
    Did someone compile and test SimplePath on a Flash build? This would be a quite crucial aspect to me whether to buy it or not.
     
  24. Runner88

    Runner88

    Joined:
    Mar 7, 2013
    Posts:
    3
    HI Alexkring

    Is it possible for Simplepath to use layers ...I mean can it find the 3rd floor in a house or is there another way to get around this...?

    Im new to this forum...hope for respond
     
  25. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    SimplePath does not work in Flash.
     
  26. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Can you be more specific about your problem?
     
  27. Runner88

    Runner88

    Joined:
    Mar 7, 2013
    Posts:
    3
    Hi Alex

    Ok ill try to be more specific.

    First of all, I really think you produckt is great, and therefore i want to keep using it ,instead of trying another produckt,but only if it can meet the repuirments, i want to use it for.

    Ok ..lets say i have an npc_1, standing somewhere in an open terrian and there also is a house in this terrain with three floors,

    and on the 2nd floor stands another npc_2,..Would simplepath then be able to let the npc_1 find the

    house, get inside and then find the stairs to 2nd floor and finenally find npc_2.....

    note: important that the npc(simplepath pathfinding) can use the stairs.

    .....Hope this explanation make more sense..
     
    Last edited: Mar 10, 2013
  28. pvzkiller

    pvzkiller

    Joined:
    Oct 3, 2012
    Posts:
    7
    Hi Alex, I just bought SimplePath and I wonder how I can rotate the PathGridWithObstacles prefab? I mean, changing it's Rotation value in Transform does nothing... My game is 2.5D and it's orientation does not fit with the one of the PathGridWithObstacles prefab. My game is much like Plants VS Zombies, and gravity is not used, so please tell me there's an easy way because I cannot change everything else just for AI to work... :eek:
     
  29. IrkenInvader

    IrkenInvader

    Joined:
    Mar 7, 2013
    Posts:
    1
    Would this be a good option if I needed something that would allow me to select a small group of units and move them around, with them avoiding each other (units leave a little space between them) while going to their destination?
     
  30. willeml85

    willeml85

    Joined:
    Dec 4, 2011
    Posts:
    23
    *fixed*
     
    Last edited: Apr 5, 2013
  31. badawe

    badawe

    Joined:
    Jan 17, 2011
    Posts:
    297
    Hey, do you have any function to get the grid of possible movements inside the grid?

    Something like this:
    $FFT_Battle.jpg

    like the blue area:
     
  32. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    Hi Alex,

    I've been using Aron Granberg's A* Pathfinding library for a while, but bought SimplePath because it looked very clean and efficient.

    In AG's library he has 'penalty' which is used in the cost computation function, which can be modified in the GraphUpdateObject, which I use. This is useful to make some nodes cost more than others, rather than simply making it a binary can/cannot travel through.

    Is there a way to do this in SimplePath?

    Cheers,
    Shane
     
  33. ShaneStevens

    ShaneStevens

    Joined:
    Nov 16, 2012
    Posts:
    14
    ... 2 weeks and waiting...

    Alex?
     
  34. BSBalazs

    BSBalazs

    Joined:
    Jul 5, 2013
    Posts:
    8
    I have a big problem with this pack...

    I want to use this in network, and I cant set the Path Manadger prefab in to Tath Agent Component on character!

    I tryed everything what I know, I tryed in Playmaker set property, but It work only in Runtime

    How can I set the PathManadger prefab in to Path Agent Component (Script) at before run??
    I imported PathManager in to gameobject variable, but I cant import this variable in to Path Agent Component (Script) in inspector.
    This game object isn't in scene, it will be create at connection
     
  35. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    Would your pathfinding code be able to handle changes in terrain... I have a tank that can blow craters in the terrain.... Maybe by constantly calling The GetTerrainHeight function mentioned in the docs?
     
  36. jayglossy

    jayglossy

    Joined:
    Aug 20, 2013
    Posts:
    7
    hi
    am currently considering buying this for my windows phone 8 project
    i just wish to know if it supports windowsphone8
     
  37. andrew-fray

    andrew-fray

    Joined:
    Jul 19, 2012
    Posts:
    155
    I tried to get in touch with Alex on twitter for a few days, but couldn't. And I don't see any other way to contact him.

    There's a bug in SimplePath's heap code that, depending on your use case, may cause failed and weird paths where they're not expected. If you have whole-integer estimates or exactly predict estimates, you will see it more. To fix, change the contents of the final else block in SimplePath/Main/Code/AI/Planning/Node.CompareTo() as follows:

    Code (csharp):
    1.  
    2.         public int CompareTo(Node other)
    3.         {
    4.             if (m_f < other.m_f)
    5.             {
    6.                 return -1;
    7.             }
    8.             else if (m_f > other.m_f)
    9.             {
    10.                 return 1;
    11.             }
    12.             else
    13.             {
    14.                 // return 0; <<-- old line
    15.                 return m_index.CompareTo(other.m_index); // <<-- new line
    16.             }
    17.         }
    18.  
    Read on for more details on this bug, when it happens, and why.

    When an open path node is explored for a second time because a new path to it is found, the score may need to be updated in the open heap. The planner does this by first removing the node, then re-inserting it.

    The heap code removes a node by sorting the heap, then doing a binary search using the above CompareTo() to find the node in question. It's then removed.

    If any two nodes have identical f values, they will be seen as identical in the binary search. The heap will then remove one of the two - which may not be the node the planner intended to remove. This removed node will never get explored, which if it was the goal node would mean the path can never succeed.

    Now you see why this is more likely to happen with round or exact estimates. By increasing the number of open nodes with identical f values, the chances of this happening increase.

    The fix works by guaranteeing a binary search using CompareTo() will always find the right node, without compromising the usual heap sorting order.

    If you want to get in touch, my twitter account is the best bet. I don't check the unity forums very often.
     
  38. ivanbolcina

    ivanbolcina

    Joined:
    Oct 27, 2013
    Posts:
    41
    Hi.

    I am having scene and am trying to get path from point A to B for some game object that lies on point A. The problem is, that this gameobject is also "footprint" component. So it obstruct itseft. I tried to modify code so that it wouldnt mind first node, but it doesnt work...
    Help please.
    BR
     
  39. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Does SimplePath work for multi level scenes as well? Eg. Navigating through several floors of a building
     
  40. RomanLov

    RomanLov

    Joined:
    May 5, 2013
    Posts:
    5
    it is real to make turn obstacles objects, or only boxed, without rotation?
     
  41. pako

    pako

    Joined:
    Nov 21, 2012
    Posts:
    111
    Hi,

    I'm a new user and I have a few questions:

    1. I created a custom Agent according to the manual's instructions, using an empty game object. Then, I attach an Interaction_Wander component and a Capsule Collider. I use this as the parent, and attach on it a prefab which holds the enemy (mesh, materials, animations). When there's just one of these, it wanders fine around the PathGridWithObstacles. However, if I put about 7 of these custom agents in the scene, then there are many collisions between the agents, and many of them get stuck quite frequently.

    Is there a way that the agents can recognize each other as obstacles, and plan their routes so that they don't collide with each other?

    2. Is it necessary that the agent's components (i.e. NavigationAgent etc.) be placed at the root GameObject? I tried placing these as children of my existing prefab and it didn't work (the agents didn't move). So, I'm not sure if I did something else wrong, or if these components must always be part of the root game object.

    3. When my custom agent wanders around, his front side never rotates to orient in the direction of the motion. It always faces the same direction. So, I guess I have to implement some kind of a "look at", or "look towards" script. In which SimplePath script should I look to find the direction of movement, so that I can use it as input for the "look towards" script? Or is there an easier way of implementing this?

    Thanks!
     
  42. killa187420

    killa187420

    Joined:
    Dec 13, 2013
    Posts:
    10
    $errors.png $errors1.png i just bought off store iam using unity 4.3.4 as soon as its done importing i get these errors how do i fix are they just part test and can i delete with no probs thank you :)
     
  43. Sebane1

    Sebane1

    Joined:
    Apr 8, 2014
    Posts:
    7
    I've recently begun creating a top down Unity2D project, but the grid scripts seem to project the grid on the z axis, wheras Unity2D only uses the XY axis.
    Me being very new to SimplePath, is there any 2D support? Especially for objects with "Rigidbody2D" interection?

    If not, would it be difficult for me to modify any logic that relates to the z axis?
     

    Attached Files:

    Last edited: Apr 8, 2014
  44. Shinugami

    Shinugami

    Joined:
    Oct 17, 2012
    Posts:
    54
    I have the exact same errors. I bought the program but it fails to function due to errors. The errors are exactly the same as shown above.

    Update:
    31st May 2014: Still no reply about the error.

    Update:
    7th April 2015: Still no reply about the error. I'd consider this asset dead. Since then there has been huge strides with Aaron's A* and Unity's Navmesh. Simple Path is Simple Dead - should be removed from asset store.
     
    Last edited: Apr 7, 2015
  45. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hi,

    Do you have local avoidance mechanism? (for agents)
     
  46. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Okay, forget the local avoidance.

    In an RTS game are units with different sizes available. One can pass through between two obstacles and the another not. Is it supported in your asset?
     
  47. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    I reply myself, i guess yes. You wrote:

    This is extremly important for me, and i was thinking about thits solution too, but in the pathfinding solution i used supports just 1 manager. Probably an another solution would be to give all nodes a max walkable size (linecast around y) and at pathfinding compare the unit size with the node size.

    Probably you update your feature list, unity user looking for this. By the way, you should rise your price, if you are an expert in pathfinding solutions, because 20$ is definitely too low.
     
  48. EvilTacoMan

    EvilTacoMan

    Joined:
    Jul 14, 2013
    Posts:
    3
    I can't seem to get the grid to follow my terrain. I have the "PathGridWithObstaclesAndHeightmap" prefab out and the terrain in dragged into the "HeightmapComponent_UnityTerrain" area with a Path manager and the basic wandering prefabs as well. It all functions well except it does not work with the terrain. I went to the uneven terrain example as well and the grid there is just a tiny square on a huge terrain?
     

    Attached Files:

  49. vicenterusso

    vicenterusso

    Joined:
    Jan 8, 2013
    Posts:
    130
    Can SimplePath just return a list of objects (path) if I give start, end and I take care of movement and animations?
     
  50. bigdaddio

    bigdaddio

    Joined:
    May 18, 2009
    Posts:
    220
    Has this guy disappeared? Is this project no longer supported?