Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Nav

Discussion in 'Navigation' started by AnonnyMoose, May 10, 2017.

  1. AnonnyMoose

    AnonnyMoose

    Joined:
    Nov 28, 2014
    Posts:
    30
    I posted this in the beta forum but got no answer, so posting here too...

    I'm working on a randomly generated city map, each tile is made up of a prefab that has its own pre-calculated navmesh, and uses Nav Mesh Prefab Instance. To connect these tiles, I am using Navmesh Links, which are set to:
    walkable,
    cost -1,
    Autoupdate Position= true,
    bidirectional = true.

    All generates correctly, the navmeshes are all connected - apart from when a navmesh agent travels across a Navmesh Link he jumps, even though it is set to walkable.

    Am I doing something wrong here? I want this to be all seamless to the player, I just want to walk normally across the link?
     
  2. Taorcb

    Taorcb

    Joined:
    Mar 15, 2015
    Posts:
    39
    To the best of my knowledge that's how NavMeshLinks work by default - the agent just teleports across. I've seen some implementations where there's a proper jump and animation (Immortal Redneck comes to mind), but I'm not sure how it's achieved. I'd be intrigued to find out.

    EDIT: I think either 5.6 or whatever they're calling the next version (Unity 2017 or something like that) has or will have runtime NavMesh generation. I can't imagine it's a fast process, though.
     
  3. AnonnyMoose

    AnonnyMoose

    Joined:
    Nov 28, 2014
    Posts:
    30
    This is using 5.6. It already has the runtime NavMesh generation, but it also has the prefab pre-generated approach which I am trying to use for speed and control. I may have no choice but to try the runtime generation instead, which worries me!
     
  4. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    a fix is coming - will land in some patch release of 5.6 too
     
    AnonnyMoose likes this.
  5. AnonnyMoose

    AnonnyMoose

    Joined:
    Nov 28, 2014
    Posts:
    30
    Oh Jakob, that would be great! Which part are you fixing?

    I've tried changing to the runtime NavMesh generation, but as predicted every time I'm creating new areas, there is a huge spike in the frame-rate even on my development PC - this game is going to be on mobile.

    So the prefab instance with someway of connecting the prefabs together without a jump would make life so much easier for anyone developing these sorts of games!

    Thanks in advance :D
     
  6. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    AnonnyMoose likes this.
  7. AnonnyMoose

    AnonnyMoose

    Joined:
    Nov 28, 2014
    Posts:
    30
  8. grimjim

    grimjim

    Joined:
    Jan 18, 2014
    Posts:
    17
    Hey, I might have the same issue. I wanted to have the agent just walk over the off mesh link, no jump or something else,
    so I tested the provided examples here, https://github.com/Unity-Technologies/NavMeshComponents
    In Scene 7_dungeon when you set the method drop down in the agent link mover script, attached to the agent, to normal speed it should just walk over I think. But it seems to just change its position to the endpoint and then stuck in an endless loop because it never reaches its position. Looks like using auto traverse off mesh. I changed the coroutine a bit and then it worked.
    My changes:
    Code (CSharp):
    1.     IEnumerator NormalSpeed(NavMeshAgent agent)
    2.     {
    3.         OffMeshLinkData data = agent.currentOffMeshLinkData;
    4.         Vector3 startPos = agent.transform.position;
    5.         Vector3 endPos = data.endPos + Vector3.up * agent.baseOffset;
    6.         float normalizedTime = 0.0f;
    7.         while (normalizedTime < 1.0f)
    8.         {
    9.             agent.transform.position = Vector3.Lerp(startPos, endPos, normalizedTime);
    10.             normalizedTime += Time.deltaTime / 0.5f;
    11.             yield return null;
    12.         }
    13.     }
    Provided:
    Code (CSharp):
    1.     IEnumerator NormalSpeed(NavMeshAgent agent)
    2.     {
    3.         OffMeshLinkData data = agent.currentOffMeshLinkData;
    4.         Vector3 endPos = data.endPos + Vector3.up * agent.baseOffset;
    5.         while (agent.transform.position != endPos)
    6.         {
    7.             agent.transform.position = Vector3.MoveTowards(agent.transform.position, endPos, agent.speed * Time.deltaTime);
    8.             yield return null;
    9.         }
    10.     }
    So just want to know if that is the bug that will be fixed or is this something else :)

    Thank you.
     
    christougher likes this.