private int AddQuailty(CrowdQuality q, bool isCheckExist) { if (m_Mgr == null) { return(-1); } int key = (int)q; int value; if (isCheckExist) { if (m_QualiyHash.TryGetValue(key, out value)) { return(value); } } CrowdAvoidanceParams param; switch (q) { case CrowdQuality.High: param = CrowdAvoidanceParams.CreateStandardHigh(); break; case CrowdQuality.Good: param = CrowdAvoidanceParams.CreateStandardGood(); break; case CrowdQuality.Mid: param = CrowdAvoidanceParams.CreateStandardMedium(); break; case CrowdQuality.Low: param = CrowdAvoidanceParams.CreateStandardLow(); break; default: return(-1); } int index = m_QualiyHash.Count; if (!m_Mgr.SetAvoidanceConfig(index, param)) { #if UNITY_EDITOR Debug.LogError("SetAvoidanceConfig error~!"); #endif return(-1); } if (!m_QualiyHash.ContainsKey(key)) { m_QualiyHash.Add(key, index); } return(index); }
/// <summary> /// Restores the object to its default state, releasing all references to existing /// configurations. /// </summary> public void Reset() { mConfigs = new CrowdAvoidanceParams[CrowdManager.MaxAvoidanceParams]; mConfigs[0] = CrowdAvoidanceParams.CreateStandardLow(); mConfigs[1] = CrowdAvoidanceParams.CreateStandardMedium(); mConfigs[2] = CrowdAvoidanceParams.CreateStandardGood(); mConfigs[3] = CrowdAvoidanceParams.CreateStandardHigh(); for (int i = 4; i < mConfigs.Length; i++) { mConfigs[i] = new CrowdAvoidanceParams(); } }
private void CheckCrowdAvoidanceSet() { if (CrowdAvoidanceConfig == null || CrowdAvoidanceConfig.Length != CrowdManager.MaxAvoidanceParams) { CrowdAvoidanceConfig = new CrowdAvoidanceParams[CrowdManager.MaxAvoidanceParams]; CrowdAvoidanceConfig[0] = CrowdAvoidanceParams.CreateStandardLow(); CrowdAvoidanceConfig[1] = CrowdAvoidanceParams.CreateStandardMedium(); CrowdAvoidanceConfig[2] = CrowdAvoidanceParams.CreateStandardGood(); CrowdAvoidanceConfig[3] = CrowdAvoidanceParams.CreateStandardHigh(); for (int i = 4; i < CrowdAvoidanceConfig.Length; i++) { CrowdAvoidanceConfig[i] = new CrowdAvoidanceParams(); } } }
public void CreateQuery(float fMoveSpeed, float fTurnSpeed) { this.mTurnSpeed = fTurnSpeed; this.mMoveSpeed = fMoveSpeed; NavStatus status = NavmeshQuery.Create(navmesh, mMaxQueryNodes, out query); if ((status & NavStatus.Sucess) == 0) { Debug.LogError( fileName + ": Aborted initialization. Failed query creation: " + status.ToString()); mCrowdManager = null; return; } mCrowdManager = CrowdManager.Create(mMaxCrowdAgents, mMaxAgentRadius, navmesh); if (mCrowdManager == null) { Debug.LogError(fileName + ": Aborted initialization. Failed crowd creation."); } CrowdAvoidanceParams mCrowdParam = CrowdAvoidanceParams.CreateStandardMedium(); mCrowdManager.SetAvoidanceConfig(0, mCrowdParam); mCrowdAgentParams = new CrowdAgentParams(); mCrowdAgentParams.avoidanceType = 0; mCrowdAgentParams.collisionQueryRange = 3.2f; mCrowdAgentParams.height = 1.8f; mCrowdAgentParams.maxAcceleration = 8.0f; mCrowdAgentParams.maxSpeed = this.mMoveSpeed; mCrowdAgentParams.pathOptimizationRange = 12.0f; mCrowdAgentParams.radius = 1.0f; mCrowdAgentParams.separationWeight = 2.0f; mCrowdAgentParams.updateFlags = CrowdUpdateFlags.AnticipateTurns | CrowdUpdateFlags.ObstacleAvoidance | CrowdUpdateFlags.CrowdSeparation | CrowdUpdateFlags.OptimizeVis | CrowdUpdateFlags.OptimizeTopo; polyResult = new uint[300]; pointResult = new Vector3[300]; tileBufferPoints = new Vector3[3000]; pointResultBuffer = new Vector3[300]; polyResultBuffer = new uint[300]; NavmeshTile tile = navmesh.GetTile(0); int count = tile.GetVerts(tileBufferPoints); Debug.Log("Tile " + tile.GetTileRef() + " count:" + count); if (count > 3000) { tileBufferPoints = new Vector3[count]; } tileBufferRef = -1; //NavmeshPoly[] polys=new NavmeshPoly[3000]; //int polyCount; //polyCount=tile.GetPolys(polys); //for (int i = 0; i < polyCount; i++) //{ // NavmeshPoly poly = polys[i]; // //if (poly.Type == NavmeshPolyType.OffMeshConnection) // { // Debug.Log("Poly" + i+"type"+poly.Type.ToString()); // } //} }