How do I build the struct for physics colliders? What I’ve tried so far is to match the struct similar to the results returned from NavMeshBuilder.CollectSources, but I have not been able to find out how to do the matrix transform for it. Here’s what I’ve got so far.
var s = new NavMeshBuildSource();
s.area = 0;
s.component = collider;
if (collider is BoxCollider)
{
s.shape = NavMeshBuildSourceShape.Box;
}
else if (collider is CapsuleCollider)
{
s.shape = NavMeshBuildSourceShape.Capsule;
}
else if (collider is SphereCollider)
{
s.shape = NavMeshBuildSourceShape.Sphere;
}
else
{
throw new System.Exception("Unsupported collider type! " + collider);
}
The localToWorldMatrix is what the API shows to use for the mesh filters, but what it gives for colliders is different than what NavMeshBuilder.CollectSources returns, and it causes the nav mesh to not be built.
Also, even what is returned by NavMeshBuilder.CollectSources doesn’t seem to take into account if the collider has a center position different than 0,0,0. Anything I can do about that?
Its a LayerMask. You can set it to the layers that you want to include as navmesh sources. You will need to declare it and set the values in the inspector.