private void Update() { GameObject target = CalculateTarget(); if (target && canPanic) { transform.position = Vector3.MoveTowards(transform.position, target.transform.position, speed * 2.0f * Time.deltaTime); } else if (waypoint) { transform.position = Vector3.MoveTowards(transform.position, waypoint.transform.position, speed * Time.deltaTime); } for (int i = 0; i < boids.Count; i++) { if (boids[i] == null) { boids.RemoveAt(i); } } if (boids.Count <= 0) { manager.Destroy(team, gameObject); } else if (boids.Count <= maxCount * 0.5f && canPanic) { script_boidGroup closest = FindClosestGroup(); if (closest) { for (int i = 0; i < boids.Count; i++) { // might not be needed if (boids[i]) { boids[i].GetComponent <Rigidbody>().velocity = Vector3.zero; // closest.AddToGroup(boids[i]); boids[i].transform.parent = closest.transform; } } manager.Destroy(team, gameObject); } } }
private void Die() { if (timerTarget < 0.0f) { for (int i = 0; i < towers.Length; i++) { StartCoroutine(towers[i].GetComponent <script_explosion>().meshSplit(true, 5)); } GetComponent <BoxCollider>().enabled = false; timerTarget = towers[0].GetComponent <script_explosion>().waitTime; } timer += Time.deltaTime; if (timer >= timerTarget) { manager.Destroy(team, gameObject); } }