News Forums RAIN General Discussion and Troubleshooting Checking pathfinding targets


This topic contains 1 reply, has 2 voices, and was last updated by  Sigil 5 months, 2 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #40094



    I need assistance in some basic things regarding AI pathfinding. We’re developing a stealth game where the player can get to places where the AI can not, so a thing that I consider as “basic” is to check the places the AI try to go before actually going there. Until now I’ve been using this RAIN built-in functions:

    1) aiRig.AI.Navigator.ClosestPointOnGraph(pos, max_y_offset) for checking if the position is on some navmesh (position is “walkable”)

    2) aiRig.AI.Navigator.GetPathTo(pos, maxPathfindSteps, maxPathDist, allowOffGraphMovement, out path) for checking if the AI can get there walking/running (position is “reachable”)

    The main problem I have now is that the second one is too expensive in terms of performance for the distance it can cover. I mean, I’m using it with parameters maxPathfindSteps = 150 and maxPathDist = 75f, and in many cases 150 steps are not enough to check reachability of points that aren’t that far away.

    Let’s put this example:


    I’ve been doing some tests here. As you can see, there are 2 floors connected with stairs (at the top left and right).
    Here, if an enemy (position A) sees you in a different floor ( position B ) I can not check the reachability of the target position because it needs more than 400 pathfind steps for the function (in 2)) to return true, and that costs more than 2ms to compute. Considering that the path (when the function returns true) is 32 meters long, I wouldn’t consider this case as “extreme”… I mean, this level is not that big, you could find cases like this one in a lot of videogames…

    Knowing this, I wonder if there’s another way to check the reachability of target positions. Any ideas?


    • This topic was modified 5 months, 3 weeks ago by  Almuva.


    Sorry for the late reply:

    400 steps is a lot to resolve, if you could show me a screen shot of the navigation mesh I might be able to help you figure out what is happening.

    One thing that’ll definitely increase the time is if one of the targets is off of the Navigation Mesh. Our pathfinding attempts to hunt for the target and that can introduce some lag. We have some improvements coming to remove that lag, but that is still in the works. I can see you were probably trying to address this using ClosestPointOnGraph, but unfortunately that has a caveat of only working if you are on an actual graph node to begin with, otherwise it just returns the same point. Not very useful I realize, and in the next version it’ll at least attempt to give you a point on a node that is close to your position.

    You can address this in your current version by using the NavigationManager. Something like this:

    List<RAINNavigationGraph> tGraphs = NavigationManager.Instance.GraphsForPoints(tRig.AI.Body.transform.position,

    If that list is empty, there isn’t a single navigation graph that can get you where you need to go, allowing you to skip the path find altogether.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.