public List <Collider2D> GetTargetsCollider2D(Act act = null) { visibleTargets.Clear(); Collider2D[] targetsInViewRadius = Physics2D.OverlapCircleAll(transform.position, viewRadius, LayerMaskUtill.Composit(targetMask)); List <Collider2D> targetCollider = new List <Collider2D>(); Debug.Log("루틴 테스트" + targetsInViewRadius.Length); for (int i = 0; i < targetsInViewRadius.Length; i++) { Transform target = targetsInViewRadius[i].transform; Vector3 dirToTarget = (target.position - transform.position).normalized;// 방향 설정 if (Vector3.Angle(transform.up, dirToTarget) < viewAngle / 2) { float dstToTarget = Vector3.Distance(transform.position, target.position); if (!Physics.Raycast(transform.position, dirToTarget, dstToTarget, LayerMaskUtill.Composit(obstacleMask))) { targetCollider.Add(targetsInViewRadius[i]); act(targetsInViewRadius[i]); } } } return(targetCollider); }
/// <summary> /// 각도를 무시하고 전체 타겟을 불러옵니다. /// </summary> /// <returns></returns> public Collider2D[] GetAllTargets() { Collider2D[] targetsInViewRadius = Physics2D.OverlapCircleAll(transform.position, viewRadius, LayerMaskUtill.Composit(targetMask)); return(targetsInViewRadius); }
public Collider2D GetTarget(Act callback = null) { Collider2D targetsInViewRadius = Physics2D.OverlapCircle(transform.position, viewRadius, LayerMaskUtill.Composit(targetMask)); if (callback != null) { callback(targetsInViewRadius); } return(targetsInViewRadius); }