예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        sqrMaxSpeed        = maxSpeed * maxSpeed;
        sqrNeighborRadius  = neighborRadius * neighborRadius;
        sqrAvoidanceRadius = sqrNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;

        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent newAgent = Instantiate(
                agentPrefab,
                Random.insideUnitCircle * startingCount * agentDensity,
                Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)),
                transform
                );
            newAgent.name = "Agent" + i;
            newAgent.init(this);
            agents.Add(newAgent);
        }
    }