Search Unity

Question CollectSources

Discussion in 'Navigation' started by Bodyclock, Jun 20, 2022.

  1. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    Hi All, am new to building the NavMeshBuilder API and just starting out with a few simple tasks just to get a feel but I seem to be stumbling at the first hurdle. I'm try to use NavMeshBuilder.CollectSources but it's not returning any sources. In my scene I have a parent object to which the Start method below is attached. As children of that object I have 2 planes and a cube. Default layer and set to static.
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         List<NavMeshBuildSource> sources = new();
    4.         List<NavMeshBuildMarkup> markups = new();
    5.         NavMeshBuilder.CollectSources(transform, 0, NavMeshCollectGeometry.RenderMeshes, 1, markups, sources);
    6.         Debug.Log("Sources found: " + sources.Count.ToString());
    7.     }
    With this simple setup I would expect to return the three sources below the transform, but no, I get 0.
    Any pointers greatly appreciated. Apologies in advance if it's something stupid on my behalf.
    Cheers
    Chris
     
  2. Bodyclock

    Bodyclock

    Joined:
    May 8, 2018
    Posts:
    172
    All good. I think I was barking up the wrong tree. Now using the Components and the NavMeshSurface. Though in my defence information was a little scattered and confusing for my pea-sized brain. :) The previous method looked like it should have worked and threw no errors o_O