private void SpawnAgents() { for (int i = 0; i < StartingCount; i++) { // spawn agent belong in this flock float randX = Random.Range(0f, 179f); float randY = Random.Range(0f, 179f); float randZ = Random.Range(0f, 179f); Vector3 randRotation = new Vector3(randX, randY, randZ); FlockAgent newAgent = Instantiate( agentPrefab, new Vector3(0, 0, 0), Quaternion.Euler(randRotation), transform ); newAgent.name = "Agent" + i; newAgent.BelongToFlock(this); // the new agent belong to this flock agentList.Add(newAgent); // add this agent into the flock } /* * foreach (var agent in agentList) { * agent.transform.position = Random.insideUnitSphere * StartingCount * DENSITY; * } */ }