Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2022.2 beta is now available for testing. To find out what's new, have a look at our 2022.2 feature highlights.
    Dismiss Notice
Dismiss Notice
Submit bug reports tagged with #Beta2022Win_Unity when you encounter unknown issues while testing the 2022.2 betas for a chance to win a year of Unity Pro. For more information, have a look at our Beta Sweepstakes Announcement.

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:
    27
    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:
    205
    Those settings are defined in the Navigation window still under Window > Navigation > Agents
     
  3. push-pop

    push-pop

    Joined:
    Jun 29, 2017
    Posts:
    27
    @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:
    205
    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:
    27
    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.
unityunity