Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NavMeshAgent doesn't update to transform position?

Discussion in 'Unity 5 Pre-order Beta' started by PhobicGunner, Jan 22, 2015.

  1. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    So I have an AI built on top of NavMeshAgent. For a number of reasons, it disables updatePosition and uses the nav agent's velocity to drive my own character physics implementation.
    This worked great in 4.6
    Now, however, I've upgraded to 5.0 (beta 20) and my characters run off... completely leaving their nav mesh agent slowly crawling along behind them.



    Is there a setting or a function I'm missing here?
     
  2. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
  3. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    Basically, with UpdatePosition turned off... you now need to manually update the NavMeshAgent's position by setting

    navMeshAgent.nextPosition = rgdBody.position

    You should check out the NavMeshAgent.nextPosition in your local version of the Scripting Reference that gets downloaded with Unity 5 beta.
     
    babstra likes this.
  4. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    It almost works, right up until the bot stops moving and just stays frozen in one spot forever (until it dies). It's as if agent.velocity is just returning zero...
     
  5. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    Paging @Jakob@Unity
     
    twda likes this.
  6. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Bump.
    Still an issue in RC1, I don't see anything in the changelog for RC2 either.

    I can see that, indeed, agent.desiredVelocity at some point just starts returning a zero vector, even though the agent has a path and a steering target which appears to be the next waypoint in the path.
     
  7. DanSuperGP

    DanSuperGP

    Joined:
    Apr 7, 2013
    Posts:
    408
    Have you submitted a bug report?

    Also, has the agent gone outside the navmesh when that happens?
     
  8. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Well, my project is actually very big, and for whatever reason I can't reproduce it in an empty project.

    HOWEVER.

    I appear to have at least band-aided the issue for now - when I call navAgent.Stop(), also calling navAgent.ResetPath() afterwards appears to completely fix the issue of my bots standing still like a bunch of idiots. Now they move around and shoot at each other just like before :)
     
    DanSuperGP likes this.
  9. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    What about the NavMeshAgent.Warp function?
    If I recall correctly that's what I used when I stumbled upon this issue.
     
    mgsvevo, ReyDidT and DanSuperGP like this.