Hi
i try to update my plugin from 4.3.77 to 4.3.82.
in new version . the navmesh is generate wrong.
old version:
new version:
what i do is:
first gen a mesh base on the map
then call AstarPath.active.Scan for the mesh
then destroy the mesh
i need to generate three mesh (TD game. one for fly unit one for ground unit. and one for build)
so i put those in IEnumerator.
generate one then destroy the mesh and generate the other.
it’s woking well in version 4.3.77. but can’t get the right result in 4.3.82
private IEnumerator DoScanAndAddNavGraph(string _rgName, string _layerName, Mesh _mesh, string _meshName, bool _isCanCutNav)
{
var rg = AddNewRecastGraph(_rgName, _isCanCutNav, _layerName);
yield return 0;
var mMeshGo = new GameObject(_meshName) {layer = LayerMask.NameToLayer(_layerName)};
mMeshGo.AddComponent<MeshRenderer>();
mMeshGo.AddComponent<MeshFilter>().mesh = _mesh; // <- THE MESH I GENERATE FOR THE MAP
yield return 0;
rg.SnapForceBoundsToScene();
var sGround = rg.forcedBoundsSize;
sGround.y = 1f;
rg.forcedBoundsSize = sGround;
yield return 0;
AstarPath.active.Scan(rg);
yield return 0;
GameObject.Destroy(mMeshGo);
yield return 0;
}
private RecastGraph AddNewRecastGraph(string _name, bool _isCanCutNav, string _scanLayerName)
{
var rg = AstarPath.active.data.AddGraph(typeof(RecastGraph)) as RecastGraph;
rg.name = _name;
rg.cellSize = 0.2f;
rg.characterRadius = 0.8f;
rg.maxSlope = 0f;
rg.rasterizeColliders = false;
rg.rasterizeTerrain = false;
rg.rasterizeTrees = false;
rg.rasterizeMeshes = true;
rg.enableNavmeshCutting = _isCanCutNav;
rg.mask = LayerMask.GetMask(_scanLayerName);
return rg;
}