Search Unity

SetDestination Fails For No Obvious Reason (5.6p2)

Discussion in 'Navigation' started by Tyrathect, Apr 25, 2017.

  1. Tyrathect

    Tyrathect

    Joined:
    Jul 10, 2012
    Posts:
    38
    I am using the "legacy" navmesh in 5.6. I can't use the new code because it fails when multiple scenes are present, and it doesn't cut holes for trees in the terrain.

    Anyway, I have an agent whose area mask is set correctly.

    it's current position (Red icon in image) has been verified as valid (it is the NavMeshHit.point returned by SamplePosition)

    the destination is a few meters away (white icon in image), and it's position has also been verfied as valid (it is the NavMeshHit.point returned by SamplePosition)

    The magenta line (barely visible under the nav mesh) is drawn from the endpoints.

    When I call SetDestination() on the agent with the verified destination, the SetDestination method returns false.

    This does not happen in 5.5

    It doesn't fail everywhere, though. Most situations work as you would expect. this one, and random other ones don't. This is new as of 5.6.

    Capture.PNG
     
  2. Tyrathect

    Tyrathect

    Joined:
    Jul 10, 2012
    Posts:
    38
    I found a workaround:

    This happens if your agent radius is zero. Sometimes the agent gets into a state where it can no longer be used. I don't know why.

    I found this because unity doesn't have a non-blocking API for getting an arbitrary path. Therefore, I had to wire up a cockamamie scheme to keep a pool of NavMeshAgents around so I could get them to figure out a path for me. I had to set the radius to zero because otherwise, I thought the agent would interfere with the pathing of actual agents.

    I think that is what will happen now.

    Why can't you guys add an ansynchronous GetPath API?
     
  3. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Yes - async path requests is soon in the works.
    If you want no interference (avoidance + collision) set the agents obstacleAvoidanceType to `NoObstacleAvoidance`
     
    Tyrathect likes this.