Search Unity

Control max jump height/distance of individual agents

Discussion in 'Navigation' started by dgoyette, Dec 12, 2017.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    I'm trying to control the ability for some characters to move across OffMeshLinks, while preventing others from doing so.

    Let's say I have two kinds of enemies, Turtles and Rabbits, and they have NavMeshAgents on them. The Rabbits should be able to jump across large gaps, or up to high ledges, while the Turtles can only make very small leaps. How is that kind of control achieved using NavMesh? It seemss that OffMeshLinks are all-or-nothing based on the bake settings, and I can't set an individual Agent to have characteristics like "Jump Distance" or "Jump Height".

    Thanks,

    -Dan
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,195
    FWIW, I made a demo showing the concept in action. I have three agents: Turtle, Rabbit, and Snail. Turtle is slow and big, and is given a low step height. Rabbit is fast, can take big steps, and can use the NavMesh Link to jump a gap. Snail can't go up steps, but he's small enough to fit through small gaps.

    I ended up with three different NavMesh Surface components in my scene (https://docs.unity3d.com/Manual/class-NavMeshSurface.html), where each mesh is associated with a different Agent Type. This causes each NavMesh Surface to be baked differently to accommodate the settings on the agent. (That is, Turtle can't get as close to walls, while Snail can get very close).

    Overall: The new NavMesh Components approach is much more powerful than the standard Unity NavMesh system. I wonder when this will be included in Unity, rather than an external GitHub project.

    Here's a video of a "race" between these three agents: