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

NavMeshSurface Runtime Bake settings

Discussion in 'AI & Navigation Previews' started by push-pop, Aug 25, 2021.

  1. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    Hi all,

    I've been using the NavMeshComponents from github: https://github.com/Unity-Technologies/NavMeshComponents

    I am basically trying to create a a floor that I can navigate around, with no steps etc...

    The problem I am running into is that I can't find a way to change the Step Height or Agent Radius when baking the NavMeshSurface, so my NavMeshAgent is walking over top of some of my obstacles. One workaround would be to scale colliders up on the Y axis but this is very messy and also messes up some other raycasting I am doing, requiring more work for a fix...

    Is there any way to change these settings currently with a runtime NavMesh build? It seems like a pretty key feature but I can't find a way to do it. Hoping it's something simple I am missing!

    Thanks
     
  2. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Those settings are defined in the Navigation window still under Window > Navigation > Agents
     
  3. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    @ChrisKurhan I found those settings, however they seem to have no effect when I create a new NavMesh from code.

    For reference, here is how I am creating the navmesh:

    Code (CSharp):
    1. var navmesh = gameObject.AddComponent<UnityEngine.AI.NavMeshSurface>();
    2. navmesh.useGeometry = NavMeshCollectGeometry.PhysicsColliders;
    3. navmesh.BuildNavMesh();

    Then this new NavMeshSurface has default settings for StepHeight, etc... I have not found a way to change them in a dynamically created NavMeshSurface
     
  4. ChrisKurhan

    ChrisKurhan

    Joined:
    Dec 28, 2015
    Posts:
    268
    Are you using a different agent type than the default one? Most likely you have to update the
    navmesh.agentTypeId
    of the
    var navmesh
    you have defined in that sample to match the agent configuration you are trying to have the NavMeshSurface for.
    The NavMeshSurface will get the details for the specified agent type when it bakes (reference here).
     
  5. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    28
    That worked! Thanks so much!

    Didn't realize those settings were actually set at the agent level and not the NavMeshSurface level
     
    ChrisKurhan likes this.