Search Unity

Continually getting "...placed on a navmesh" errors, despite warping to known point on mesh

Discussion in 'Navigation' started by BenP_Leda, Sep 12, 2019.

  1. BenP_Leda

    BenP_Leda

    Joined:
    Aug 17, 2015
    Posts:
    4
    I've got a navmesh agent which I need to move under physics control, so I fire "navMeshAgent.updatePosition = false;" before starting the movement so that my agent does not interfere.

    When the physics movement is over, I use NavMesh.Sample to get the nearest position on the navmesh to my transform.position, then use "navMeshAgent.Warp(hit.position)" to move the agent to this location before setting updatePosition to true.

    The NavMesh.Sample call is returning true, and the NavMeshHit data is populated, but I'm still getting "... can only be called on an active agent that has been placed on a NavMesh" errors - even though I have deliberately warped the agent to a point that NavMesh.Sample is telling me is on the NavMesh!

    Can anyone shed any light on this as it's doing my head in!!! Thanks!
     
  2. Grizmu

    Grizmu

    Joined:
    Aug 27, 2013
    Posts:
    131
    Since your agent is disabled, try assigning the sample hit.position to the agent's transform.position, instead of using the warp method. Then you should be able to re-enable the agent.