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

SamplePosition bug or undocumented behavior?

Discussion in 'Navigation' started by snacktime, Oct 25, 2017.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Querying SamplePosition with a point that's not on the navmesh, is not returning a hit even when there is one well inside the query range.

    Is this expected? If so why?
     
  2. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Here is a pic showing the stuck position. This is actually not an easy problem to solve. You can't prevent an agent from landing outside the navmesh easily. Moving with velocity or obstructions can easily cause an agent to land on even just 0.01 units away from the destination, causing SamplePosition to then fail.

    And there is no good way I can think of to get the closest point on the navmesh that will line up correctly with the final destination. You can't just for example query a point in the direction of the destination, because like in this pic the destination direction could just lead off the edge of the dock. Resulting in an odd looking first step out of this situation.

    I thought of storing the last destination point, but that fails in my case also, because agents can leave the navmesh (to get on a boat) and then get placed back on the navmesh in a different location.

    upload_2017-10-25_2-46-54.png
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Actually nevermind all that, this has to be a bug pretty much by definition. I'll just work around it as best I can for now.