With multi-dimensional model as the core, let the factory digital transformation and upgrading “within reach”>>>
The main reason is that the navmesh points of two identical objects are too close
Solution: get walkable points through navmesh.sampleposition
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);
}
}
}
Similar Posts:
- Limit the range of axial movement in unity mathf.clamp
- Unity – NullReferenceException: Object reference not set to an instance of an object
- Unity realizes lookat in 2D
- Error: Setting the parent of a transform which resides in a Prefab Asset is…
- Rigidbody.moveposition rigid body movement
- InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor ‘…
- sklearn.utils.validation.check_random_state(seed)
- Unit delay methods: invoke and invokerepeating
- Git Bash Run “ssh-add pathName” Error: “Could not open a connection to your authentication agent.”
- [Solved] redisson Error: IllegalArgumentException: port out of range:-1