Beispiel #1
0
        private void Start()
        {
            squareMaxSpeed        = maxSpeed * maxSpeed;
            squareNeighbourRadius = neightbourRadius * neightbourRadius;
            squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;

            for (int i = 0; i < startingCount; i++)
            {
                Vector3    newPos   = Random.insideUnitSphere * startingCount * AgentDensity;
                FlockAgent newAgent = Instantiate(agentPrefab, new Vector3(newPos.x, transform.position.y + 1, newPos.z),
                                                  Quaternion.Euler(Vector3.up * Random.Range(0f, 360)), transform);
                newAgent.name = "Agent " + i;
                newAgent.Initialize(this);
                agents.Add(newAgent);
            }
        }