private void VisionToFood(GameObject food) { Vector3 foodPos = food.transform.position; Ray ray = new Ray(chicken.transform.position, foodPos - chicken.transform.position); foreach (RaycastHit2D hit in Physics2D.RaycastAll(ray.origin, ray.direction, foodRange.radius * 3)) { if (hit) { if (hit.collider.gameObject.CompareTag("Chicken Sensory Range") || hit.collider.gameObject.CompareTag("Chicken")) { continue; } else if (hit.collider.gameObject.CompareTag(foodTag)) { chicken.FoodDetected(food); } else { break; } } } }