예제 #1
0
 // Start is called before the first frame update
 void Start()
 {
     enemyList.Add(this.gameObject);
     timeSinceBoidCalc = 0f;
     spriteRenderer    = GetComponent <SpriteRenderer>();
     boidScript        = GetComponent <Boids>();
     moveVector        = boidScript.CalculateBoid(enemyList, FetchNeighbors(), target).normalized;
 }
예제 #2
0
 // Update is called once per frame
 void Update()
 {
     if (timeSinceBoidCalc > .2f)
     {
         timeSinceBoidCalc = 0f;
         moveVector        = boidScript.CalculateBoid(enemyList, FetchNeighbors(), target).normalized;
     }
     else
     {
         timeSinceBoidCalc = Time.deltaTime + timeSinceBoidCalc;
     }
     transform.position += moveVector * speed * Time.deltaTime;
 }