I need to get the direction from the center of my screen, so I used camera.transform.forward, but that only works when my field of view is at its default 60. Let’s say I want it to be 25, how do I calculate the correct offset from the actual center now?
The center of your screen is the one spot where the FOV has absolutely no effect.
You can always use camera.ScreenPointToRay(somePoint) to get the exact direction to any given point on the screen.
Using the helper function that @StarManta posted above is always going to be the simplest thing to do. You can collide that given Ray against a Plane or physics colliders.
As far as the math, the FOV means "how many degrees from straight ahead to the top edge of my field of view. It’s only valid with non-oblique camera frustums, which is 99.999% of use cases.
That means the angle between the top of your screen and your eye and the bottom of your screen is 2x the fieldOfView.
Same thing goes for .orthographicSize when you’re in orthographic: the size is half the height of the viewport.
You can actually use Mathf.Tan or Mathf.Atan and see that it comes out right for perspective cameras.
Keep in mind Tan and Atan work in radians not degrees. Mathf.Deg2Rad and Mathf.Rad2Deg are two helper constants to switch between radians and degrees.
Thank you very much!