Skip to content
Snippets Groups Projects
Select Git revision
  • 244f1d34216e3e90cd77ec1d5c6110a6cf1bed7f
  • main default protected
2 results

SMA.cs

Blame
  • SMA.cs 1.03 KiB
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class SMA : MonoBehaviour
    {
        public List<Agent> agents;
        public Environnement environnement;
        public int population = 80;
        public GameObject boid;
    
    
        // Start is called before the first frame update
        void Start()
        {
            createEnvironnement();
            createAgents();
        }
    
        // Update is called once per frame
        void Update()
        {
            
        }
    
        void createEnvironnement() {
            //environnement = new Environnement();
            //environnement = gameObject.AddComponent<Environnement>() as Environnement;
            environnement = GameObject.Find("Environnement").GetComponent<Environnement>();
        }
    
        void createAgents() {
            GameObject a;
            for(int i=0; i<population; i++) {
                a = Instantiate(boid, environnement.validPosition(), Quaternion.identity,environnement.transform) as GameObject;
                agents.Add(a.GetComponent<Agent>());
            }
    
        }
    
    }