Search Unity

Mesh left behind Nav Mesh Agent

Discussion in 'Navigation' started by RavenOfCode, Oct 20, 2016.

  1. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    So I have a really weird issue, the mesh is actually getting left behind the agent and sometimes teleports to the agent or doesn't move till the agent comes back to the mesh.

    They are all basic agents with some movement code and have a kinematic rigidbody.

    Here's what I see when I run the game and look in the scene view:
    bandicam 2016-10-19 18-58-15-566.jpg bandicam 2016-10-19 18-58-18-750.jpg bandicam 2016-10-19 18-58-20-149.jpg
     
  2. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Im assuming that the kinemetic aspect is causing the issue. You could in code have the rigidbody location be set to the agent location.
     
    RavenOfCode likes this.
  3. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    It doesn't seem to be that, the agent with or without physics still has this issue and moving the rb to the agent does nothing.
     
  4. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Can you share a pic of your inspector window of the gameobject in question? And by the looks of the pictures you sent maybe the rigidbody is somehow bring caught by the other blocks ? Is the rigidbody component a child or parent of the object that holds the agent ? That might cause this issue..
     
  5. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    I doubt thats the issue, as I said I doubt it has anything to do with physics, as the issue persists with and without physics (even with the colliders set as triggers and no rb attached). Anyways here's my inspector:
    InspectorView.png
    The rb is not a child, infact nothing is as there are no children objects.
     
  6. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    All looks good to me there. Maybe one of your scripts are setting transform position or doing something weird.
     
    RavenOfCode likes this.
  7. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    I think I fixed it, if I set the transform.position to the navMeshAgent.nextPosition in my targeting calcualtions coroutine it works, yet if I use rb.position it doesn't work which is odd. Still thanks for recommending to set the position to the agent! I'll let you know if the issue comes back, thanks again! :)
     
  8. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    RavenOfCode likes this.
  9. RavenOfCode

    RavenOfCode

    Joined:
    Apr 5, 2015
    Posts:
    869
    That would do it, I completely forgot about that. I guess I didn't realize that the agent is still active yet the gameobject isn't. Thanks!
     
  10. Songfugel

    Songfugel

    Joined:
    Jan 2, 2019
    Posts:
    2
    I know this is old thread, but another thing that can cause this exact same thing is if the GameObject is set to static by accident when assigning static attributes for the NavMesh