Search Unity

FindClosestEdge of NavMeshSurface?

Discussion in 'Navigation' started by imaginationrabbit, Nov 3, 2017.

  1. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    Is there any way to use FindClosestEdge with a NavMeshSurface? Or any way to CalculateTriangulation on a NavMeshSurface component?

    I tried accessing the navMeshData on the surface but that only gives you position, rotation, bounds etc-

    Thanks-
     
  2. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
  3. imaginationrabbit

    imaginationrabbit

    Joined:
    Sep 23, 2013
    Posts:
    349
    It works from an agent on a mesh- I was creating a script to automatically add navmesh links to procedural rooms using Navmesh surfaces- so I was trying to call FindClosestEdge from a non agent object-

    What I ended up doing was using the box colliders on the room pieces and using ClosestPoint on the colliders to auto create Navmesh links- script for anyone interested here https://github.com/mdotstrange/MyUnityScripts/blob/master/GenerateNavLinks.cs
     
    christougher likes this.