Search Unity

Manually moving agent and it does not follow! Stuck on higher ground!

Discussion in 'Navigation' started by hippocoder, Jul 6, 2017.

  1. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hello,

    I'm using the new navmesh components from github. I have an agent and use this code:
    Code (CSharp):
    1.             agent.updateRotation = false;
    2.             agent.updatePosition = false;
    I then use it's desiredVelocity to work out what direction to move my AI unit in and update it with:
    Code (CSharp):
    1.         agent.speed = runSpeed;
    2.         agent.velocity = rb.velocity;
    3.         agent.nextPosition = transform.position;
    But my problem is that the agent cylinder (in wireframe debug) is getting stuck on higher ground and does not follow even though I am clearly setting agent.nextPosition each frame.

    This is game-breaking because other AI avoid the stuck capsule on higher ground and not where I am on the lower ground after I jump down. AI and player units will often get knocked down to lower ground and there is still navmesh there. We cannot use links everywhere and should not have to.

    Walking back up and down frees the otherwise constrained agent representation (cylinder).

    Any advice is welcome since I do need the avoidance and so on but need to handle movement.
     
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Which version of Unity are you using ?

    We do have an issue in 5.6 and below - where agents can get stuck at creases when moved "manually" - but fixed in 2017.1. Maybe this is a different issue, feel free to submit a (preferably minimal) repro and ping me w. case #
     
    Last edited: Jul 7, 2017
  3. hwc1935

    hwc1935

    Joined:
    Mar 8, 2016
    Posts:
    2
    @Jakob_Unity Hi, I seem to be having a similar issue, and I am currently using 5.6. I am trying to use nextposition to move my nav agent to an island in the navmesh that is only connected by offmesh links, but the nav agent never gets placed onto that position, but rather the closest position to it while still on the current connected part of the navmesh it is in( meaning the closest point to the island but not on the island ) Is this the issue that is in 5.6? Should I update unity or is there a work around?
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    @Jakob_Unity to clarify, I should never have to use Warp if I am using nextPosition / manual movement? It seems the only hack I can do is to warp the agent when it lands after a jump.

    As I am doing 100% manual movement and positioning, it seems odd that the agent nextPosition doesn't move it outside of a navmesh edge.

    I thought warp was only for agents controlled by Unity and not under manual control?

    I am currently using 2017.1 b10.
     
  5. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    Ok - i think i misunderstood the problem then.
    Are you trying to move over a link ? That is not supported by 'nextPosition' - It only traverses polygons.

    Basically you'll have to call "CompleteOffMeshLink" to logically snap the agent to the landing side of the link.
    And in order for that to work - a path containing the link is required - i.e. an offmeshlink/navmeshlink is not visible to an agent unless the agent has a path containing that link.
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hello Jakob,

    Unfortunately that's not what I want, links aren't relevant as I want to update the internal position when my characters move around - they may jump via special moves or the player's one might need to be updated when the player chooses to fall off.

    I see a few threads like this but no solution (where the developer wants full authoritative control over the object, while using navmesh velocities etc for data - ie querying where the navmesh agent would've moved if it could've moved).

    Is that what warp is for?. I tried it but it rooted my player on the spot :(

    (I might have a map with no links, but bounce pads or even an explosion force may have knocked npcs or players down where there is no link).
     
  7. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    I think I am running into something similar. Have you come up with a solution hippocoder?
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I think I ended up just calling warp when the character landed or something - don't recall. Wish things were all a bit clearer in this area of Unity.
     
  9. JohnTomorrow

    JohnTomorrow

    Joined:
    Apr 19, 2013
    Posts:
    135
    Yeah, I agree. I did the same, seems to work.
     
  10. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    This is fixed in the patch release from today :)
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    eh?! so I have no idea what is fixed as I'd already worked around everything I could....