Search Unity

5.6 Nav - OffMeshLinks cause agents to snap to positions incorrectly

Discussion in 'Navigation' started by superdupergc, Apr 23, 2017.

  1. superdupergc

    superdupergc

    Joined:
    Jun 21, 2013
    Posts:
    28
    Just updated from 5.5.0f3 to 5.6.0f3. This affects both OffMeshLink and NavMeshLink.

    I'm using some code similar to the example code to manually have agents traverse Off Mesh Links. When using agent.transform.postion = Vector3.MoveTowards(...), my agents are snapping to incorrect positions and not able to leave those positions. It feels related to how navmeshagents will snap to the nearest navmesh - these are on a navmesh surface, but not the nearest surface, and not the surface they were on or the target point is on.

    This problem affects the example code in the github repo too - https://github.com/Unity-Technologies/NavMeshComponents - just try the 7-Dungeon scene and change the AgentLinkMover's m_method to NormalSpeed instead of Parabola. Edit: For some reason, Parabola works (even in my setup), I guess because it's using Lerp instead of MoveTowards? But I don't understand why that makes a difference.

    It's like something else - not the Vector3.MoveTowards - is causing it to move a large distance in one frame. Right after setting the position with MoveTowards, the position is updated by something else, so that the next frame, the current position is not what I set it to last frame. I have no other scripts setting position, and, like I said, this happens in the example code too.

    Edit: I figured this out. Apparently, you have to turn off agent.updatePosition in 5.6, even when you are on an offmeshlink that's being handled manually. This was not the case on 5.5.0f3.
     
    Last edited: Apr 24, 2017
    ahorne, CrymX and christougher like this.
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Nice catch - it's still a bug unfortunately - i'm investigating.
     
    CrymX likes this.
  3. superdupergc

    superdupergc

    Joined:
    Jun 21, 2013
    Posts:
    28
    At least there's a workaround :)
     
  4. weitay

    weitay

    Joined:
    Aug 5, 2012
    Posts:
    10
    Hi,

    came across the same problem.

    My agents have a rigidbody component added to them. And it seems that they stop teleporting when IsKinematic is set to true... hope this helps in the bug hunt
     
  5. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Thank you... I was loosing my mind