Search Unity

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

SimplePath - Advanced Pathfinding for any Game Genre - RELEASED

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

  1. liquidgraph

    liquidgraph

    Joined:
    Feb 26, 2009
    Posts:
    324
  2. flim

    flim

    Joined:
    Mar 22, 2008
    Posts:
    326
    I download the latest v1.1 and import in my Android project. I haven't use any SimplePath feature yet, but when I build my project, I got 5 errors:
    My project can build without SimplePath in my Asset folder. Any idea what's happening?
     
  3. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
    Flim, thats because SimplePath references the Terrain engine that currently doesn't work on iOS and Android, so it is referencing API calls that it cant support.

    I would assume this is a new issue introduced in 1.1 and that Alex hasn't put some compiler platform conditions within his code to not refer to API that doesn't exist on certain platforms.
     
  4. flim

    flim

    Joined:
    Mar 22, 2008
    Posts:
    326
    OIC, so what is the expect release date for next update?
     
  5. HJP

    HJP

    Joined:
    Jul 8, 2009
    Posts:
    152
    :)
     
  6. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    It no longer appears to compile on iPhone?

    (It runs fine in the editor, but spouts errors then compiling).

    Says: "Assets/Standard Assets/SimplePath/Main/Code/AI/Navigation/Pathing/PathGrid.cs(33,25): error CS0246: The type or namespace name `Terrain' could not be found. Are you missing a using directive or an assembly reference?"

    Any idea how to do a quick fix?

    - Adam G
     
  7. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Ahh man, I didn't catch that. I don't have my iOS license anymore so I wasn't able to test on iPhone for the release of 1.1. Alright this is totally my fault, I'm going to buy the iOS license and fix this as quickly as I can. I'll have the fix out before the end of day Sunday (the 19th).

    For now, the quick fix would be to search for these two variables: m_heightmap and m_optionalHeightMap, and change their datatype from "Terrain" to "IHeightMap", then you will have to define an interface called IHeightMap, as follows:

    Code (csharp):
    1.  
    2. interface IHeightMap
    3. {
    4.      float SampleHeight(Vector3 position);
    5. }
    6.  
    Any reference to the Unity Terrain object should be replaced with this IHeightMap data type. This is the same change that I am going to make, and then I'll provide an implementation of IHeightMap that has a Unity Terrain object data member, and is only on iPhone.

    Actually I'm going to shoot for getting this done today, but I will guarantee I will have the fix by this Sunday.
     
  8. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    Where about's do we place the interface IHeightMap code please?/ Which scripts?
     
  9. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    In IPathTerrain.cs
     
  10. Hilm

    Hilm

    Joined:
    Nov 2, 2007
    Posts:
    338
    Getting an xcode error stating "RegisterClass_TerrainData()"
     
  11. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Anyone happen to know exactly which platforms unity terrain works with?
     
  12. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Delete the "TerrainData" in SimplePath->Examples->Resources folder.
     
  13. psyclone

    psyclone

    Joined:
    Nov 17, 2009
    Posts:
    245
    Currently work with all but the Mobile Platform (Android and iPhone)
     
  14. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    I have the fix working locally, but I want to test it on someone else's PC.. anyone that I can send the package to who wants to test it out?
     
  15. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    well, someone that also runs on iphone
     
  16. HJP

    HJP

    Joined:
    Jul 8, 2009
    Posts:
    152
    PM Hilm or flim.

    I am on a Mac or PC ... I have a normal handy ... :)

    Heinz
     
  17. liquidgraph

    liquidgraph

    Joined:
    Feb 26, 2009
    Posts:
    324
    I can test it. I'm running Mac and iPhone. PM me. Please specify which changes were made so I can adjust my modified version of 1.1.
     
  18. seon

    seon

    Joined:
    Jan 10, 2007
    Posts:
    1,441
  19. Unamine

    Unamine

    Joined:
    Mar 23, 2011
    Posts:
    28
    Awesome!!!
    Too bad it is not free as well as the unity :(
    I would like a free version, which at least had fewer resources, such as the last update of the land illegally
     
  20. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Version 1.11 has been submitted to Unity. This version primarily fixes the compatibility issues for android and iphone that were introduced in version 1.1. I tested these changes on iphone and android, with several different users. Additionally, I added an IHeightmap class for creating your own heightmap to interface with SimplePath, if you desire.

    Finally, I reduced the price back to $60.
     
  21. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    What is the performance on iPhone and Android?
     
  22. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    I haven't done any performance profiling for these devices, I've only done profiling for the PC build. All I can say about performance on iphone, is that I was able to run one of the test scenes that had 20 agents, at well over 60FPS. Of course, a lot of different things factor into performance, and it's hard to say how fast the game will run without knowing more about your game. You can control performance through several tuning variables in the PathManager (see the documentation for controlling performance http://www.alexkring.com/SimplePath/SimplePath.pdf, under the section that describes the PathManager). If you have any questions specific to the product you are making, I'd be happy to answer!
     
  23. DFJohn

    DFJohn

    Joined:
    May 20, 2009
    Posts:
    15
    Good to see some awesome unity stuff from my old roomie! :)
     
  24. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Thanks John! I saw that you're at Naughty Dog now, I'm sure you're having a blast there :] You'll have to tell me more about it sometime.
     
  25. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    1.11 is now available in the asset store.
     
  26. agentsmith

    agentsmith

    Joined:
    May 1, 2010
    Posts:
    132
    Does simple path provide a way to pick different paths to reach a destination? For example if I have 3 enemies closing in on the player, some of the pathfinding extensions I used before the enemies would start to line up on the same path like a train. Perhaps providing a function/method that can be called to get additional paths?

    Also if two enemies are on the same path but the one that is behind is moving faster will he walk around the enemy in front of him like the "dynamic obstacles"? Or can I tag an enemy to be an "obstacle" so he'll walk around him?

    Thanks!
     
  27. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    There's a lot of depth to this question. First, agents will rarely lineup like a train, for many reasons (ex: the pathsmoothing algorithm favors the most direct route, as does the planner). Another facet of this problem, is good destination selection. Agents should never be given the same destination position as one another. Typically this is handled by some other system, that determines good destination positions for the agents. For example, if there are three agents that want to kill the player, some sort of "BattleTokenManager" ought to tell those agents if they can attack, and if so, where they should move to. One additional thing that I haven't added, that I ought to add, is what I call a QuickPath check. Anytime a navigation request is generated, the QuickPath check should do a 2D raycast across the grid, to first determine if the agent can just move directly to their goal. If so, then they travel in a straight line to the goal, without any planning. SimplePath has support for this raycast (which is linear in time), via the Raycast2D function call. However, this raycast check is not integrated into the navigation system. Though, it should only be a handful of code lines to get this working.

    There is no support for this behavior. Though the system has been setup to allow the user to easily extend the steering code, since steering is often customized in every game. There have been several people who have integrated UnitySteer with SimplePath, which is one option. You can tag anything with a collider as a dynamic obstacle, by attaching a footprint component. However, giving a footprint component to an agent that navigates around the world produces undesirable results, since the agent will try to avoid his own footprint.
     
  28. agentsmith

    agentsmith

    Joined:
    May 1, 2010
    Posts:
    132
    Ah gotcha thanks for the info!
     
  29. c-Row

    c-Row

    Joined:
    Nov 10, 2009
    Posts:
    847
    Wouldn't it be possible to tag the agent's own footprint so he ignores it? Or tag others as well? Think of a large map with a river in the middle. You could add a "is_water" tag to it to set up a footprint - which could then be ignored by a hovercraft unit for example by adding this layer to an "ignoreFootprintLayers()" array. Might be an idea for a future version...?
     
  30. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    That's a good line of thought. I think for this example, I would create two two separate grids. One for hovercrafts, and one for characters that can move through land and water. SimplePath supports having multiple grids, and characters being members of different grids, but it doesnt support having obstacles being rendered only into specific grids / layers. Though, this would not be a difficult addition! Thanks for the feedback.
     
  31. 3Duaun

    3Duaun

    Joined:
    Dec 29, 2009
    Posts:
    600
    +1, we use SimplePath(such a great tool!), and could use just what c-Row is describing
    we need this for enemies with varying speeds, and varying means of traversing the terrain(by land or air)
     
  32. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    Is it possible to use simple path to do path finding for a character controller rather than an AI? What I'm trying to do is allow the player to select a point in the scene and then have the character controller navigate to that point.
     
  33. djinni69

    djinni69

    Joined:
    May 10, 2010
    Posts:
    174
    Alex - just a heads up, I setup my Agents with footprints but I also made the goal radius a little bigger than default, and I'm seeing great results. Just wanted to pass it on
     
  34. AntonioT

    AntonioT

    Joined:
    Feb 3, 2010
    Posts:
    17
    I'm trying to use the Uneven terrain example to get an idea of how to use it correctly but all I get is a blue screen when I try run it ?

    Also, when I use the standard patrol actor, my scene gets very jerky even though the unity stats window says I have above 50 fps. Is anyone else having performance issues with simple path ?
     
  35. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    There's only a few references to the rigidbody, and they are all inside the SteeringAgentComponent. Just change all these references to your character controller instead (I think there's maybe 6 places where you need to change rigidbody.velocity to charactercontroller.velocity). SimplePath only needs a rigidbody for setting velocity.
     
  36. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Fantastic! Can you post your application, or a video of this behavior? I'd be really interested to see this working
     
  37. djinni69

    djinni69

    Joined:
    May 10, 2010
    Posts:
    174
    Alex - I PMed a link to you!
     
  38. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    You might be looking at the game window, i didn't setup the camera in this scene to be in a good location. Take a look at the Scene window.
     
  39. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    I gave it a shot, but it seems to be a little more complex than I thought based upon your comment. Any chance this could end up as "out of the box" functionality in a future update. FWIW, it's a pretty common scenario for an RTS style game.
     
    Last edited: Jun 24, 2011
  40. leebe

    leebe

    Joined:
    Jul 17, 2009
    Posts:
    48
    Alex, great plugin! Here is a video of our new game in development and we are using Simple Path for the unit pathing.

     
  41. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    I don't plan on adding out of the box support for character controllers, because I feel that it would add complexity to a product that I want to keep simple. I can help you add support for character controllers if you like, it should only take about 10 minutes.
     
  42. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Awesome! The game looks very polished. When does this release?
     
  43. pneill

    pneill

    Joined:
    Jan 21, 2007
    Posts:
    207
    First, let me say kudos to you for saying "no." I love that you have a vision for you product and you're sticking to it. I have to admit the simplicity and ease of the product is one of the reason I really like as opposed to other options out there.

    With respect to your offer of help me. I would really welcome that. What's the best way to move forward?
     
  44. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    1. Replace the existing SteeringAgentComponent.cs file with the contents in this file: http://www.alexkring.com/SimplePath/SteeringAgentComponent.txt
    2. Search the code for [RequireComponent(typeof(RigidBody))] and replace it with [RequireComponent(typeof(CharacterController))]. There are two occurrences.
    3. For each of the 3 actor prefabs (Actor_Patrol, Actor_Wander, and Actor_Chase), you want to add the character controller and remove the rigidbody. To do this In the unity editor, select the prefab, then go to Component->Physics->Character Controller. A box will pop up with 3 buttons. Press the "Replace" button. Then, remove the RigidBody component from the prefab.

    You know, I might actually make this the default setup, since it produces better looking results when two actors collide. They will slide off one another, which looks better than what happens when two rigidbodies collide.

    Also note that I added a mass variable to the steeringagent component, so if you find that your actors are not accelerating downward enough (from gravity) then you either need to increase the value of this variable, or the value of the gravitational acceleration variable.
     
    Last edited: Jun 24, 2011
  45. runner

    runner

    Joined:
    Jul 10, 2010
    Posts:
    865
    Hello alexking

    #1 Timely customer support without the long waits
    #2 Updated product with new features with at least 2 revisions
    #3 Provide tips for all manners of game types

    Listen to customer complaints and provide alternative workarounds

    Purchased
     
  46. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    Thanks! I hope SimplePath works out for you :]
     
  47. Goldrake

    Goldrake

    Joined:
    Feb 6, 2010
    Posts:
    148
    Hello,
    i bought SimplePath and now i'm trying to setup it on my project.
    I have many street (not on a plane) and houses.
    Now i need that simplepath calculates the path on the street and the houses are the obstacles.
    Because of as i told the street is not on a plan i think that i need the navmesh path or should i take the height of the street and pass it to the grid?
    The terrain with heightmap is not a solution because the game will run on ipad.
    I red carefullty all the docs ans the threads of the forum but i can't understand how to set the navmesh or the height from the street mesh.

    Can alex or anyone explain me how to do it?

    P.S: there is anyone???

    Thank you very much
     
    Last edited: Jun 27, 2011
  48. runner

    runner

    Joined:
    Jul 10, 2010
    Posts:
    865
    Okay maybe im dense as to where these code blocks go in SteeringAgentComponent the last goes in update() could you please explain in simple laymen terms Thanks

    Code (csharp):
    1. public Vector3 SeekPos
    2.     {
    3.         get
    4.         {
    5.             if (m_path == null)
    6.                 return transform.forward;
    7.  
    8.             float currentDistAlongPath = m_path.MapPointToPathDistance(transform.position);
    9.             float futureDist = currentDistAlongPath + m_lookAheadDistance;
    10.             return m_path.MapPathDistanceToPoint(futureDist);
    11.         }
    12.     }
    Code (csharp):
    1.             Vector3 lookPosition = steeringAgentComponent.SeekPos - transform.position;
    2.             if (lookPosition != Vector3.zero)
    3.             {
    4.                 Quaternion fromQuat = transform.rotation;
    5.                 Quaternion toQuat = Quaternion.LookRotation(lookPosition, Vector3.up);
    6.                 transform.rotation = Quaternion.Lerp(fromQuat, toQuat, Mathf.Clamp(5.0f * Time.deltaTime, 0.0f, 1.0f));
    7.             }
    8.            
     
  49. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    You will need to define some data structure that inherits from IHeightmap. There is one function in that interface that defines the height of the terrain. This is currently hooked up to the Unity Terrain object, but you can create your own component and hook it up to a mesh or whatever object you like, just as long as you define this function. There is documentation for this in the user's manual (assuming you have the latest version, 1.11). Let me know if this works out.
     
  50. alexkring

    alexkring

    Joined:
    May 5, 2011
    Posts:
    368
    I think someone else posted this code on this thread at some point. But it looks like the first block of code is caching the SeekPos. The seekpos is the position that the agent is traveling toward, and this position always lies upon the path he is following. The seekpos is also always ahead of the agent's current position along the path. If this code is confusing, I would suggest displaying this point in the debug rendering.

    The second block of code is rotating the agent to face the seekpos. This will make the agent face forward along his path.