16 return 2f * Mathf.Atan(Mathf.Tan(camera.fieldOfView * Mathf.Deg2Rad * 0.5f) * camera.aspect);
25 public static bool IsInFOV(
this Camera camera, Vector3 position)
27 float verticalFovHalf = camera.fieldOfView * 0.5f;
28 float horizontalFovHalf = camera.GetHorizontalFieldOfViewRadians() * Mathf.Rad2Deg * 0.5f;
30 Vector3 deltaPos = position - camera.transform.position;
33 float yaw = Mathf.Asin(headDeltaPos.x) * Mathf.Rad2Deg;
34 float pitch = Mathf.Asin(headDeltaPos.y) * Mathf.Rad2Deg;
36 return (Mathf.Abs(yaw) < horizontalFovHalf && Mathf.Abs(pitch) < verticalFovHalf);