Using the new navigation components with Unity 2017… just curious if there are any plans to allow Heightmap baking anytime soon–I see that the checkbox is grayed out and the documentation says “Not supported.” Without this, it seems that the character hovers quite a bit off the ground–I assume I could fix this by messing with the base offset, but I’m still curious about the height map. Thanks!
You can change the voxelsize in the NavmeshBuildSettings (smaller voxel size improves the quality of the navmesh). This will create a much better navmesh, but unfortunatley your baking will take much longer as well.
Thanks for the response! I figured this out already–unfortunately, it seems like you have to use the same voxel size parameter for each entity (I have several of varying radii) to get good results. Since this is dependent on the radius, it seems that larger entities simply require more ‘voxels per radius’ and thus take longer to build. Either way, this will work for now.
While messing around with this, I did come across odd behavior–specifically, why does a larger built radius place the character higher and higher off the ground? I would think that the radius has nothing to do with the height offset. You can test this easily by building multiple navmeshes on a flat surface and see that they form ‘layers’ where the ones with higher radii are further from the surface on which they are built. Odd…
If you’re not too concerned about performance in the short term, you can try a solution which corrects for incorrect height positioning at runtime:
private void CorrectBaseHeight()
{
NavMeshHit navhit;
if (NavMesh.SamplePosition(GameObject.transform.position, out navhit, 10f, NavMesh.AllAreas))
{
Ray r = new Ray(navhit.position, Vector3.down);
RaycastHit hit;
if (Physics.Raycast(r, out hit, 10f, LayerMask.GetMask("Level")))
{
_nav.baseOffset = -hit.distance;
}
}
}
Hello, I am trying to do a voxel terrain with procedurally generated voxel blocks and NavMesh everything almost works perfectly other than my character can’t go up the blocks, I tried to use NavMeshLink however that doesn’t work well in my situation. Thankfully I found a way of fixing it on a not procedurally generated terrain made out of voxel blocks. If I decrease the voxelSize to 1 voxel per agent radius then everything works smoothly but I can only change it manually and not from a script. However, I know that it has something to do with NavmeshBuildSettings.voxelSize = 0.5f; but I really have no idea how to implement it. I would be really thankful if you could help me. Thank you!
Ive also had problems with the height of the generated navmesh. I couldnt find any solution (so far) @rcabot wrote a function that looks too heavy for me.