public void Init(PathfindingSetting setting) { // 设置NavmeshSurface的参数 _surface = gameObject.GetComponent <NavMeshSurface>(); if (_surface == null) { _surface = gameObject.AddComponent <NavMeshSurface>(); } _tileSize = setting.tileSize; _surface.collectObjects = CollectObjects.Volume; _surface.defaultArea = RuntimePathfinding.areaDetail; _surface.center = Vector3.zero; _surface.size = new Vector3(_tileSize + 0.5f, _tileSize * 8.0f, _tileSize + 0.5f); }
public void Init(PathfindingSetting setting) { _surface = gameObject.GetComponent <NavMeshSurface>(); if (!_surface) { _surface = gameObject.AddComponent <NavMeshSurface>(); } _surface.size = new Vector3(setting.tileSize * 0.98f, setting.tileSize * 8.0f, setting.bakeLinkAreaWidth); _surface.center = Vector3.zero; _surface.collectObjects = CollectObjects.Volume; _surface.defaultArea = RuntimePathfinding.areaBakeLink; _sampleCount = setting.linkBakeSampleCount; _navmeshPath = new NavMeshPath(); _samplePosArrayOne = new Vector3[_sampleCount]; _samplePosArrayTwo = new Vector3[_sampleCount]; _offset = _surface.size.z * 0.25f; }