void updateExpression(FlockAgent fa) { GameObject[] missiles = GameObject.FindGameObjectsWithTag("Explosion"); float c = 0; float sumDist = 0; foreach (GameObject m in missiles) { sumDist += Vector2.Distance(fa.transform.position, m.transform.position); c++; } if (sumDist / c < scaredDistance) { fa.changeExpression(ExpressionGenerator.Emotion.Scared, scaredDuration); } }