主要緣由是:兩個相同對象navmesh點太近形成。dom
解決方案:經過NavMesh.SamplePosition 得到能夠行走點ide
for(int i = 0;i<100;i++) { float fRadius = Random.Range(0, mRadius); float fAngle = Random.Range(0, 3.14f); Vector3 v3 = mStartPos; v3.x += Mathf.Sin(fAngle) * fRadius; v3.z += Mathf.Cos(fAngle) * fRadius; NavMeshHit hit; if(NavMesh.SamplePosition(v3, out hit, mRadius, 1)) { GameObject p = Instantiate<GameObject>(mCat, hit.position, Quaternion.identity, transform); if (p != null) { NavMeshAgent agent = p.AddComponent<NavMeshAgent>(); if(agent!=null) { agent.speed = 5.0f; } mCatList.Add(p); } } }