Search Unity

Apex Path v2.0 [RELEASED] - High Performance, Easy to use dynamic Pathfinding

Discussion in 'Assets and Asset Store' started by Reinholdt, Jul 16, 2014.

  1. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    1,021
    Hi @Geminior,

    I have checked out the forum link and will try later.

    Thanks for the assistance.

    doc
     
  2. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    We are currently having some serious issues with our site host resulting in apexgametools.com being unavailable most of the time. We are working to sort it out.
     
  3. Mithion

    Mithion

    Joined:
    Dec 12, 2013
    Posts:
    14
    Hello,

    I am trying to use Apex Path in my game but am running into some issues. I will try to explain them here as best as I can.

    I am using Behaviour Designer w/ Movement Pack alongside Apex Path.

    Basically, I have a world that is generated at runtime using a smooth voxel terrain engine. I overlaid a heightmap navmesh on it, set up the layers, told it to raytrace, and it appears to be generating the nav grid perfectly. Great!

    The problem is, when I try to tell the units to move, I keep getting an error:
    Unit 'Peasant(Clone)' ((18.7, 10.6, 45.9)) reports: StoppedNoRouteExists moving towards: (0.0, 0.0, 0.0).

    I know I need to spawn the units after the grid generation, so I subscribed to the proper events and did so - the strange part is that I only seem to get that issue in the top-left subsection of the grid (-Z, +X) and only in the leftmost (-Z) 18-21 grid squares. Any other location that I tell the unit to move to works perfectly as intended. It's because of this that I believe I am subscribing to the events properly. The below image will hopefully help me explain (http://imgur.com/cXPEpvJ):



    In the image, you can see that the grid is generated properly. The blue area I have highlighted myself, and it's only in this area that the path seems to be set to 0,0,0. I have set breakpoints inside the behaviour that actually does the movement and the variable being passed in is the correct value. Anywhere else on the grid, movement is working and pathing is correct.

    I've stepped through the code and up to the point where
    Code (CSharp):
    1. public QueueItemFifo(T item, int priority, int entryOrder)
    is called, the values are still all present. No breakpoints are hit where a path point of (0,0,0) is queued.
    So I don't believe the issue is with Behaviour Designer.

    I'm hoping that you can help me shed some light on the issue that I'm seeing here. I'm really not sure why something like this is happening.
     
  4. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    The engine reports NoRouteExists in cases where the destination is unreachable. In addition to the path finder reporting this when a valid destination cannot be reached, it will also report it if the destination is not on the grid.

    The latter sounds like it could be the case in your scenario. Being 'on the grid' means being inside the grid bounds, and while the area you highlighted is clearly inside the x-z bounds, I wonder if it is inside the y bounds.
    The upper and lower boundary setting on the grid controls its y-bounds.

    The fact that it is reporting (0,0,0) as the intended destination is a bug.
     
  5. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    601
    Hi

    I'm using Apex Path alongside Dungen in order to create runtime grids for procedural dungeons but it seems Apex is ignoring the geometry generated at the start of the scene. I made sure I only called the Grid generator after the geometry is created (I even tried waiting 10 seconds), that there's no grid component in the Game World and that all layers are set in the colliders and in the Layer Mapping component but every time I get this:



    I know the runtime grid detects the geometry because it sets its size and position according to it:

    Code (CSharp):
    1.  public void GenerateGrid()
    2.         {
    3.             //Calcular tamaño escenario
    4.             var bounds = new Bounds();
    5.             foreach (var r in levelGeometry.GetComponentsInChildren<MeshRenderer>())
    6.             {
    7.                 bounds.Encapsulate(r.bounds);
    8.             }
    9.  
    10.             //Generar grilla
    11.             var cfg = new GridConfig
    12.             {
    13.                 cellSize = 2f,
    14.                 generateHeightmap = false,
    15.                 heightLookupType = HeightLookupType.QuadTree,
    16.                 heightLookupMaxDepth = 5,
    17.                 lowerBoundary = 1f,
    18.                 upperBoundary = 10f,
    19.                 obstacleSensitivityRange = 0.5f,
    20.                 sizeX = (int)bounds.extents.x,
    21.                 sizeZ = (int)bounds.extents.z,
    22.                 subSectionsX = 2,
    23.                 subSectionsZ = 2,
    24.                 subSectionsCellOverlap = 2,
    25.                 origin = bounds.center,
    26.                 obstacleAndGroundDetection = ColliderDetectionMode.Mixed
    27.             };
    28.  
    29.             //Create the grid instance
    30.             var grid = GridComponent.Create(this.gridHost, cfg);
    31.  
    32.             //Initialize the grid
    33.             grid.Initialize(10, g =>
    34.             {
    35.                 Debug.Log("Grilla lista");
    36.             });
    37.  
    38.         }

    In the Editor I have no problems so my question is: is there something I'm missing?

    Regards.
     
  6. Kondor0

    Kondor0

    Joined:
    Feb 20, 2010
    Posts:
    601
    Haha of course! 5 minutes after posting this I find the solution: the grid generated was too high: I took the center of the geometry as the center for the grid but it should be at the same height as the floor, zero in this case.

    Once I changed that, the grid generated correctly... well, I leave this here in case someone makes the same mistake as me.
     
  7. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Good to hear that you solved it.
     
  8. magique

    magique

    Joined:
    May 2, 2014
    Posts:
    4,030
    I'm going to be trying to do some AI for a flying dragon and I'm wondering if it's possible to use Apex Path for a flying entity? I just want to use the Basic Steering with local avoidance as advertised, but obviously without having the unit fixed on the ground. Is that possible?

    EDIT: I found a very old post that says that flying pathfinding is not possible. So, just confirming that this is still true. If so, will there ever be a solution? I don't believe a 3D matrix is required if you are just steering and avoiding obstacles. Perhaps there could be a method to turn on/off ground pathing and free the entity from the ground whereby it could then simply steer in space and avoid obstacles.
     
    Last edited: Feb 26, 2016
  9. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Flying does not necessarily require 3D path finding. If you have a simple setup where flying units basically move the same as ground units, i.e. planar movement (xz), but is simply at a higher elevation that is no problem and does not require 3D path finding.

    If the scenario is slightly more advanced, where some obstacles don't extend into the air space of the flying units, then you have two options. Either represent such obstacles as dynamic obstacles where the exception is set to flying units, or have a second grid placed at the flying height so that flying units navigate on that instead.
     
  10. Apex Game Tools

    Apex Game Tools

    Joined:
    Dec 22, 2015
    Posts:
    10
    Apex Utility AI is on the horizon!

    We are releasing a new AI product within the next 14 days, Apex Utility AI

    You can get more information about the Utility AI here

    The first tutorial video is uploaded "Survival Shooter Introduction"



    I have created a Survival Shooter playlist, we will be adding videos over the next coming days as soon as they are ready!

    Remember to subscribe!

    Let us know what you think!

    / The Apex Team
     
    Johnny-Casual and docsavage like this.
  11. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Can you give me some idea of the memory overhead for a grid? Also how expensive is it to handle dynamic obstacles? Specific use case is I need a bunch of smaller grids where structures can be built/destroyed. These are predefined areas of the world where when players claim them, I want to enable a grid based solution with dynamic obstacles. I'll have a large number of these but most are 100 units. Areas not claimed get handled by a navmesh.
     
  12. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    The size of each cell depends on a number of things, but the largest impact is the type of height navigation used.
    The simplest cell has around a 25byte footprint (no height navigation), the standard cell uses around 30bytes and the more advanced cell that enables units to have individual height navigation capabilities uses up to around 100bytes.

    If a height map is used instead of live ray casting, the size grows. How much depends on the variation in the terrain and the granularity. Worst case (all points in the terrain are at different heights) for a 100 by 100 grid thats 1mill plots of 4 bytes, i.e. around 4MB. Best case 4bytes.

    Dynamic obstacles are practically free. They will add 4 bytes to each cell they cover, but will use very little cpu. Particularly stationary dynamic obstacles, they literally are cost free cpu wise.
    Have a look at the demo.
     
  13. micuccio

    micuccio

    Joined:
    Jan 26, 2014
    Posts:
    143
    Hi!

    I have a quick question concerning apex : if the scale of the Agent is very small will I have any issues?
    I mean, is there any real limitation with the scale?

    Thanks in advance,

    Dom
     
  14. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Integer maths is used in cost calculations, so once the grid cell size goes below 1 inaccuracies will occur.
    This is just the default behaviour however so it can be overridden.
     
  15. Ninjaxim

    Ninjaxim

    Joined:
    Jul 23, 2013
    Posts:
    105
    Hey @Geminior,

    I'm having trouble getting Apex Path working in WebGL. To be sure it wasn't any other package causing the issue, I built out one of the included examples in a new project here: http://www.phatrobit.com/projects/ApexTest/ (I built the Basic Height Map example scene)

    As far as I know, the error appears whenever a unit moves using MoveTo. I'm using Unity 5.3.4f1 and tested using Firefox and Chrome.

    Any help would be much appreciated!
     
  16. AbyssWanderer

    AbyssWanderer

    Joined:
    Mar 15, 2016
    Posts:
    77
    Hey all.
    Please, help me to decide whether purchasing APEX pathfinding and its extentions will solve my problem.

    In my strategy most units cannot turn where they stand - they have some turn radius.
    And if they cant' turn because of the obstacle, they stop, move reverse while turning the opposite direction.
    See picture:
    - green unit looks North
    - its waypoint is at South-East
    - green arrows represent front moving
    - orange ones represent reverse reverse Question to APEX.png

    Now the question is: can I set APEX to handle this?
    For example, can I:
    1) Create vector field (small white arrows) for unit as if its turn radius equals 0
    2) Turn as a unit with non-zero turn-radius
    3) When unit sees the wall in 2-3 squares ahead, it slows down and stops right before the wall
    4) Then it looks on the arrow under it and decides to move reverese and to turn the opposite direction
    5) When unit passed 2 squares, it checkes wheteher it "looks" at Waypoint:
    - if angle between front and line to waypoint < X degrees, then start front moving
    - else keep moving reverse for another 2 squares and make a check again.

    Maybe I'm writing a crap, and APEX pathfinding has other solutions for such cases?
    And anyway, will such units be able to avoid other units? For example, if they create shifted avoid-area when turning? For example, on this picture unit was moving West and decided to turn South:
    Question to APEX 2.png

    Sorry, if any of my questions were silly - I am not a programmer by any means. But I have a programmer to tune this asset, if it can handle this cases.
    So? Can it?

    Thanks in advance!
     
  17. carlosrovira

    carlosrovira

    Joined:
    Dec 23, 2014
    Posts:
    58
    Maybe is the same problem I had with multithreading? Webgl doesn't support it. See this: http://apexgametools.com/forums/topic/apex-path-webgl/
     
  18. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Pardon the late reply, but luckily @Carlos Rovira already provided the answer, thanks Carlos.
     
  19. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Apex Steer will not solve your use case out-of-the-box. Apex Steer does provide vector fields, but the actual steering behaviours you describe would need to be implemented by you.
    Apex Path and Steer provides the foundation for this of course, so all you need to do is provide the actual steering logic.

    You can see how this is done here.
     
  20. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Does Apex Path and steering deterministic?
     
  21. Galahad

    Galahad

    Joined:
    Feb 13, 2012
    Posts:
    72
    How can I select units programmatically?
     
  22. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    The path finding is deterministic and with the exception of steering behaviours that are inherently random, e.g. Wander, steering is also deterministic
     
  23. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    You have two options.
    1. Do it via the built-in selection using GameServices.gameStateManager.unitSelection.

    2. Control unit selection yourself. There is no requirement that the built-in selection is used, so if you prefer your own solution that is not a problem. You just need write a custom Input Controller as well in that case.
     
  24. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Thanks
     
  25. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Hello @Geminior,
    I wanna ask you some question about Apex Steer. Sorry if this not the thread for apex steer. I just find this post are more vibrant and both products are developed by your company.

    1. Is Apex Steer components all also deterministic?
    2. How to setup local avoidance?
    I found this on Apex Steer website. How could I do that?
     
  26. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Let me start by informing you that we also have dedicated forums for the products, which are monitored more frequently than this thread.

    1. No Steering is not deterministic as it is float based. It does not however have the same impact as path finding as steering only apply small corrections, whereas a non-deterministic path finder might return two entirely different paths.

    2. Apex Steer will add local avoidance to units by default (when using quick starts, e.g. Navigating Unit).
    To have a unit ignore other units you must set their Determination to a higher value than the units it should ignore.
    This is set on the Unit Component.
     
  27. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Thanks and noted about the dedicated forums. About steering, if the only problem is the float operation, does that mean it will be non-deterministic across different machines but also deterministic on the same machine?
     
  28. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Yes, with the exception of steering behaviours that are inherently random, e.g. wander.
     
  29. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Thanks @Geminior, just one more question: is there any random steering behaviours enabled by default? And except for wander what else do I need to remove to guarantee the determinism?
     
  30. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    There shouldn't be more. It must be said that we have not created any of the assets with determinism in mind, so it may be that I have overseen an implementation detail in one or more behaviours that will break determinism.
    Should that be the case, it should become obvious soon enough.
     
  31. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    How to put a walking animation for characters? or how to stop animation when character reaches to the target?
     
    Last edited: Apr 17, 2016
  32. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Have a look at this article or this video.
    The tutorial project itself is found here.
    There are a few differences between the article and the project since Apex Path has evolved since the article, however the core of it is the same.
     
    ksam2 likes this.
  33. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    In Apex Path, how can I move agent by code? Is there any method equivalent to Agent.SetDestination and Agent.Stop in Unity navmesh?
     
  34. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    There are many examples on this in the Examples Project included with the product.
    You can also have a look at this and other tutorial videos.
     
  35. tr1stan

    tr1stan

    Joined:
    Jan 23, 2009
    Posts:
    150
    Hello @Geminor, how to setup apex path to make sure some units to completely ignore other group of units? e.g. I have "ground" units and "air" units the "air" units will fly on top of "ground" units while them still trying to avoiding other nearby "air" units.

    I've tried to use "Attribute Groups" for this issue. However, those units in two different attribute groups looks like they won't avoid units in different groups but block the way of other units instead.
     
  36. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    I assume that by 'Attribute Groups' you mean that you have assigned your flying units with a 'Flying' attribute and the ground units with a 'Ground' attribute on the Unit Component.
    To have them ignore each other you must also set the Steer for Unit Avoidance component's 'Ignored Units' setting so e.g. flying units have 'Ground' listed here.
    In the next update the Steer for Separation component will have a similar setting.
     
  37. mkgame

    mkgame

    Joined:
    Feb 24, 2014
    Posts:
    592
    Hello again,

    do you support now steering vehicles, which have different speed and different size and different turning speed? And also, that they should not collide, because physical moving vehicles could behave strange. Needed for an RTS game with physical moving vehicles. Local collision avoidance with steering vehicles needed in a way, that they not collide with each other, don't even touch each other, and dynamic obtacles. This also for different unit size and speed.

    Thanks for your answer.
     
  38. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    We do not have out-of-the-box support for vehicles. The default settings are for humanoids so to have vehicles you would need to reconfigure the defaults.
    Speed settings are unit based so each unit can have whatever speed settings you want.

    Differently sized units are supported, with the exceptions that dynamic obstacles are not supported and currently neither are connector portals.

    For proper avoidance you will need Apex Steer. The local avoidance included with Apex Path is very basic.
     
  39. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    After updating to Unity 5.4 now I have an error on my scene. I don't know how to solve this.

     
  40. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    We will have a look, however since 5.4 is in beta, it may just be a bug and not a breaking change.
    Unless you are sampling heights outside the grid, you can simply comment out the section in GameServicesInitializerComponent that adds this height map, i.e. the body of the InitializeAutoComponents method.

    By the way, please use the forum to report bugs.
     
  41. frankalonso

    frankalonso

    Joined:
    Aug 3, 2015
    Posts:
    13
    Hello, is there a way to have a unit lock on to a target? So it handles recalculating the path if the target moves to a new location?

    I wasn't sure how this should be approached with Apex Path - the brute force solution would be to cache the target position and check if the target's position changed in Update() and if it did call unit.MoveTo(newDestination, false), but that doesn't seem like the right way to do it.

    Do you have any suggestions?

    Also, I was curious if there is a code sample for adding the Navigation Unit component to an object at runtime (or if this was possible), and what the minimum components needed to get the system running would be - I am currently using custom locomotion using by implementing IMoveUnits with Move, Rotate, and Stop as in your example.
     
    Last edited: Jun 7, 2016
  42. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    1) Reacting to a target relocating is a job for the AI, so it is not built in to Apex Path.

    Typically your AI will run at some interval in which case it is a reasonable approach to simply check if the target has moved and if so issue a new move order.
    Optimally you will also check if the target has moved enough to justify a new move order, e.g. the target having moved less than half a cell size would not really matter as the path would be the same.

    Doing it every frame in Update however is not a good idea. The path finder needs some time to operate so doing if too often may lead to overloading the path finder.

    2) You can add navigation components to units at runtime using the QuickStarts class, e.g. calling QuickStarts.NavigatingUnit(...). You will however have to configure the various components, so you may instead want to reference the QuickStarts code to see what is added and make your own script to add and configure the components at the same time.

    You can also simply add a quick start at design time and look at the Apex Component Master to see which components are added. The debugging component added is of course not required.
     
  43. frankalonso

    frankalonso

    Joined:
    Aug 3, 2015
    Posts:
    13
    Thank you very much for the quick reply and thorough feedback! I was able to implement everything, but I've been stuck on one error:

    When adding the the NavigatingUnit quickstart by calling QuickStarts.NavigatingUnit(gameObject, false); - it states that the gameobject does not have a component of type IMovingObject.

    I am calling this in the Start() method of my custom class PathfindingManager.cs which implements IMoveUnits, handling the movement for the character. I've tried calling this before the PathfindingManager.cs component is added and I seemed to get the error that way as well. Then I tried adding all the individual components separately instead of using QuickStart, but I still seemed to receive that error. I feel like I must be making some simple mistake - if the order components are getting added is incorrect or if I should be doing something manually in the initialization process.

    The error doesn't seem to persist any problems since the AI work as expected after it fires but I would imagine that it should be a red flag that some initialization isn't happening correctly.

    Here is the full error below:

    MissingComponentException: Game object Player(Clone) does not have a component of type IMovingObject.
    Apex.SharedUnityExtensions.As[IMovingObject] (UnityEngine.GameObject go, Boolean searchParent, Boolean required) (at c:/Development/Apex Applications/ApexGameTools/Source/ApexShared/ApexShared/SharedUnityExtensions.cs:209)
    Apex.Units.UnitFacade.Initialize (UnityEngine.GameObject unitObject) (at Assets/Apex/Apex Path/Scripts/Units/UnitFacade.cs:600)
    Apex.GameState.GameStateManager.GetUnitFacade (UnityEngine.GameObject unitGameObject, Boolean createIfMissing) (at Assets/Apex/Apex Path/Scripts/GameState/GameStateManager.cs:77)
    Apex.GameState.GameStateManager.RegisterUnit (UnityEngine.GameObject unitGameObject) (at Assets/Apex/Apex Path/Scripts/GameState/GameStateManager.cs:123)
    Apex.Units.UnitComponent.Awake () (at Assets/Apex/Apex Path/Scripts/Units/UnitComponent.cs:278)
    UnityEngine.GameObject:AddComponent()
    Apex.SharedUnityExtensions:AddIfMissing(GameObject, Boolean, UnitComponent&) (at c:/Development/Apex Applications/ApexGameTools/Source/ApexShared/ApexShared/SharedUnityExtensions.cs:431)
    Apex.SharedUnityExtensions:AddIfMissing(GameObject, Boolean) (at c:/Development/Apex Applications/ApexGameTools/Source/ApexShared/ApexShared/SharedUnityExtensions.cs:448)
    Apex.QuickStarts:NavigatingUnit(GameObject, Boolean) (at Assets/Apex/Apex Path/Scripts/QuickStarts.cs:81)
    PathfindingManager:Start() (at Assets/_Source/Character/PathfindingManager.cs:38)

    Line 38 of PathfindingManager.cs: QuickStarts.NavigatingUnit(gameObject, false);
     
  44. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Due to how the Unity object life cycle works, you need to disable the game object before applying the quick start and then reenable it again afterwards.

    By the way, please use the forums for questions of this sort, as they are much more likely to help others as well.
     
  45. mrdl2010

    mrdl2010

    Joined:
    Jun 1, 2016
    Posts:
    23
    it's almost 2 year anniversary, are you going to have a sale soon?
     
  46. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    We may very well do a 2-year anniversary sale, but it is not 100% certain at this point.
     
  47. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Hi,

    Can possible 3d space AI game with Apex?

    Is it only solution for ground-based agents ? Is there any 3d systems available? It may be possible to do A* on a cubical grid.

    In advance thank you.
     
  48. Geminior

    Geminior

    Joined:
    Feb 12, 2014
    Posts:
    322
    Apex Path and Steer only support navigation on the xz-plane.
    It is certainly possible to do A* on a 3D matrix, but the 3rd dimension makes path finding considerably slower.
    We have thought about making a 3D product, but so far it is not something we plan to do as the customer base is too small.
     
  49. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Thanks for reply.
     
  50. Alverik

    Alverik

    Joined:
    Apr 15, 2016
    Posts:
    417
    Pardon me for my illiterate question, but does APEX Path work for procedurally created dungeons/levels? I've been looking to use Dungeon generators such as DunGen for some of my upcoming projects, but as the levels would be procedurally generated there's just no pre-baking the Navmesh. So, I was looking for a path finding solution which can help me overcome this obstacle. Anyways, APEX has caught my attention, so here I am.