Exemple #1
0
    void spawnAgent(Vector3 pos, string name)
    {
        FlockAgent newAgent = Instantiate(
            agentPrefab,
            pos,
            quaternion.Euler(Vector3.up * Random.Range(0f, 360f)),
            transform
            );

        newAgent.name = name;
        newAgent.initialize(this);
        agents.Add(newAgent);
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        squareMaxspeed         = maxSpeed * maxSpeed;
        squareNeighbourRaduius = neighbourRadius * neighbourRadius;
        squareAvoidanceRadius  = squareNeighbourRaduius * 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))
                                              , this.transform);
            newAgent.name = "Agent " + i;
            newAgent.initialize(this);
            agents.Add(newAgent);
        }
    }
Exemple #3
0
    public void restart()
    {
        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent NewAgent = Instantiate(
                agentPrefab,
                (Random.insideUnitCircle * startingCount * AgentDenstity * 2),
                Quaternion.Euler(Vector3.forward * Random.Range(0, 360)),
                transform

                );
            NewAgent.name = "Agent" + i;

            //Now it knows what flock it belong to
            NewAgent.initialize(this);
            agents.Add(NewAgent);
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        squareMaxSpeed       = maxSpeed * maxSpeed;
        squareNeighborRadius = neighborRadius * neighborRadius;
        squareAvoidRadius    = squareNeighborRadius * avoidRadiusMultip * avoidRadiusMultip;

        //init the flock in random rotations and positions
        //add then to the flcok array
        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent newAgent = Instantiate(
                agentPrefab,
                Random.insideUnitSphere * startingCount * AgentDensity,
                Quaternion.Euler(Vector3.one * Random.Range(0, 360f)),
                transform
                );
            newAgent.name = "Agent " + i;
            newAgent.initialize(this);
            agents.Add(newAgent);
        }
    }
Exemple #5
0
    // Start is called before the first frame update
    void Start()
    {
        squareMaxSpeed        = maxSpeed * maxSpeed;
        squareNeighborRadius  = neighborRadius * neighborRadius;
        squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;


        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent NewAgent = Instantiate(
                agentPrefab,
                (Random.insideUnitCircle * startingCount * AgentDenstity * 2),
                Quaternion.Euler(Vector3.forward * Random.Range(0, 360)),
                transform

                );
            NewAgent.name = "Agent" + i;

            //Now it knows what flock it belong to
            NewAgent.initialize(this);
            agents.Add(NewAgent);
        }
    }