When dealing with military games, especially FPS, we need to define a waypoint value, by its capacity, to be a good cover point with the maximum visibility for shooting or reaching other enemies visually. This recipe helps us compute a waypoint's value given these parameters.
We need to create a function for checking whether a position is in the same room as others:
public bool IsInSameRoom(Vector3 from, Vector3 location, string tagWall = "Wall") { RaycastHit[] hits; Vector3 direction = location - from; float rayLength = direction.magnitude; direction.Normalize(); Ray ray = new Ray(from, direction); hits = Physics.RaycastAll(ray, rayLength); foreach (RaycastHit h in hits) { string tagObj = h.collider.gameObject.tag; if (tagObj.Equals(tagWall)) return false; } return true; }