public void DrawFOV(bool precise) { Vector3 viewAngleA = DirFromAngle(-FOVAngle / 2, false); Vector3 viewAngleB = DirFromAngle(FOVAngle / 2, false); Debug.DrawLine(refPoint.transform.position, refPoint.transform.position + viewAngleA * OcclusionLib.GetDistance(target.transform, refPoint.transform)); Debug.DrawLine(refPoint.transform.position, refPoint.transform.position + viewAngleB * OcclusionLib.GetDistance(target.transform, refPoint.transform)); if (precise) { foreach (Vector3 point in CalculateRayPoints(FOVResolution)) { if (!OcclusionLib.CheckIfVisiblePrecise(point, refPoint.transform, targetCollider, FOVAngle, occlusionMask)) { Debug.DrawLine(refPoint.transform.position, point, Color.red); } else { Debug.DrawLine(refPoint.transform.position, point, Color.green); } } } else { if (OcclusionLib.CheckIfVisible(targetCollider, refPoint.transform, FOVAngle, occlusionMask)) { Debug.DrawLine(refPoint.transform.position, target.transform.position, Color.green); } else { Debug.DrawLine(refPoint.transform.position, target.transform.position, Color.red); } } }
void Update() { DrawFOV(precise); StatusText.text = "Distance: " + OcclusionLib.GetDistance(target.transform, refPoint.transform) + "\n"; StatusText.text += "CheckIfVisible: " + OcclusionLib.CheckIfVisible(targetCollider, refPoint.transform, FOVAngle, occlusionMask).ToString() + "\n"; StatusText.text += "CheckIfInFOV: " + OcclusionLib.CheckIfInFOV(target.transform.position, refPoint.transform, FOVAngle).ToString() + "\n"; StatusText.text += "CheckIfOccluded: " + OcclusionLib.CheckIfOccluded(targetCollider, refPoint.transform, occlusionMask).ToString() + "\n"; }