public override void Reset() { base.Reset(); _State = AITurnStep.RequestingSightCheck; }
public IEnumerator CheckVisionForTaggedObjects(string tag) { _State = AITurnStep.CheckingSight; EnemiesInSight.Clear(); Debug.Log("Starting Search"); GameObject[] taggedObjects = GameObject.FindGameObjectsWithTag(tag); Debug.Log("Starting Sight Check"); foreach (GameObject obj in taggedObjects) { if(CheckDirectSightOnTransform(obj.transform)) { EnemiesInSight.Add(obj.transform); Debug.Log("Spotted Enemy"); } //Vector3 direction = obj.transform.position - transform.position; //float angle = Vector3.Angle(direction, transform.forward); ////Debug.Log(angle); //if (angle < LOSAngle * 0.5f) { // RaycastHit hit; // if (Physics.Raycast(transform.position, direction.normalized, out hit, SightRange)) { // //Debug.Log(hit.collider.tag + " " + hit.collider.name); // //Debug.DrawLine(transform.position, hit.point, Color.cyan, 10f); // if (hit.collider.tag == tag) { // EnemiesInSight.Add(obj.transform); // Debug.Log("Spotted Enemy"); // } // } //} yield return null; } Debug.Log("Finished"); _State = AITurnStep.DeterminingActions; }