// 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; }
// 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; }