Search Unity

Getting PathComplete for obviously invalid paths

Discussion in 'Navigation' started by vtchalakov, Sep 3, 2016.

  1. vtchalakov

    vtchalakov

    Joined:
    Nov 9, 2013
    Posts:
    13
    I was wondering if the following was a known bug or if I am doing something wrong.

    I have a navmesh setup, where I take the user input (mouse left click + position) and then raycast that from the camera to the scene to either hit an object or get the intersection point between the raycast and the player XZ plane. This is the point I use then for the nav mesh agent, using SetDestination. I am having times where the path that is calculated however is showing up as PathComplete instead of PathPartial. I click somewhere completely away from the navmesh, in the abyss, and the point that I see returned (through Debug.DrawLine) is where I would expect it to. However the path calculated is still complete. This seems like a bug on unity's side right?

    The reason I ask is because if I get a partial path, I do a navmesh raycast to find a point between the player and the point I had clicked, that is on the navmesh, so that I can guarantee that every player click produces a valid path.
     
  2. MathiasDG

    MathiasDG

    Joined:
    Jul 1, 2014
    Posts:
    114
    If I'm not wrong, Unity's pathfinding will always find a path.
    If the path destination is not a valid point, it will find the closest valid point to it, and the result will be a path to this valid point.

    Partial / Complete paths mean that the path calculation is incomplete or complete. It has nothing to do with the path being able to connect the input parameters.

    I don't really use Unity's navmesh myself, so I'm not 100% sure of it. But usually that's what happens on pathfinding algorithms.
     
  3. vtchalakov

    vtchalakov

    Joined:
    Nov 9, 2013
    Posts:
    13
    MathiasDG likes this.