using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public class GroupTacticsEnemyCommunication : MonoBehaviour { public float communicationRange = 15f; private List nearbyEnemies = new List(); void Update() { Collider[] colliders = Physics.OverlapSphere(transform.position, communicationRange); // Clear the list of nearby enemies nearbyEnemies.Clear(); foreach (var collider in colliders) { if (collider.CompareTag("Enemy") && collider.gameObject != gameObject) { nearbyEnemies.Add(collider.transform); } } // Coordinate with nearby enemies CoordinateWithEnemies(); } void CoordinateWithEnemies() { foreach (Transform enemyTransform in nearbyEnemies) { FoV enemyAI = enemyTransform.GetComponent(); if (enemyAI != null && enemyAI.CanSeePlayer()) { // Implement group tactics here // For example, you might instruct other enemies to surround or flank the player GroupAction(enemyTransform); } } } void GroupAction(Transform enemyTransform) { // You can implement group tactics here, for example: // enemyTransform.GetComponent().SetDestination(/* Some coordinated position */); } }