public override Transform Search(ManageFactions.Faction faction, Vector3 head) { RaycastHit hit; Debug.DrawRay(head, attackTarget.position - transform.position); if (Physics.Raycast(head, attackTarget.position - transform.position, out hit, 100, ~ManageFactions.instance.deployableShield, QueryTriggerInteraction.Ignore)) { if (hit.transform == attackTarget) { return(attackTarget); } } return(null); }
public override Transform Search(ManageFactions.Faction faction, Vector3 head) { RaycastHit[] hits = Physics.SphereCastAll(transform.position, data.searchRadius, transform.forward, 0); foreach (RaycastHit hit in hits) { Health targetHealth = hit.transform.GetComponent <Health>(); RaycastHit confirmHit; if (targetHealth != null && targetHealth.faction != faction && Mathf.Acos(Vector3.Dot(transform.forward, (hit.transform.position - transform.position).normalized)) * Mathf.Rad2Deg < data.searchCone) { Debug.DrawRay(head, hit.transform.position - transform.position); if (Physics.Raycast(head, hit.transform.position - transform.position, out confirmHit, 100, ~ManageFactions.instance.deployableShield, QueryTriggerInteraction.Ignore)) { if (confirmHit.transform == hit.transform) { return(hit.transform); } } } } return(null); }
public override Transform Search(ManageFactions.Faction faction, Vector3 head) { RaycastHit hit; if (attackTarget != null) { Debug.DrawRay(head, attackTarget.position - transform.position); if (Physics.Raycast(head, attackTarget.position - transform.position, out hit, 100, ~ManageFactions.instance.deployableShield, QueryTriggerInteraction.Ignore)) { if (hit.transform == attackTarget) { //hasView = true; return(attackTarget); } } //hasView = false; return(null); } if (protectTarget != null) { Debug.DrawRay(head, protectTarget.position - transform.position); if (Physics.Raycast(head, protectTarget.position - transform.position, out hit, protectDistance, ~ManageFactions.instance.deployableShield, QueryTriggerInteraction.Ignore)) { if (hit.transform == protectTarget) { if (hit.transform.GetComponent <Health>().IsDead()) { protectTarget = null; //hasView = false; return(null); } //hasView = true; return(protectTarget); } } //hasView = false; return(protectTarget); } return(null); }
public abstract Transform Search(ManageFactions.Faction faction, Vector3 head);