0
\$\begingroup\$

I have a camera that I have set to

RenderType = Base
Projection = Perspective
FOV Axis = Horizontal
Field of View = 75
Physical Camera = False
Clipping Planes Near = 0.3, Far  = 1000

enter image description here

If I set Field of View values during gameplay in the Inspector, it works as expected.

For example, I type 75, and the camera behaves as I think it should. I'm comparing with Resident Evil 4. It has a camera cheat, and if I select FOV 75 in this cheat, the Resident Evil 4 camera behaves like my Unity game camera.

However, when I set the camera.fieldOfView to a 75 by code, the Inspector shows 104, and the code does not look as it looks when I type 75 in the Inspector.

_camera.fieldOfView however returns 75.

What is going on here, and how do I fix it?

Thank you!

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Perhaps I got a solution. Not sure yet but it looks ok so far:

private void pSetFOV(float f)
{
    f = 2 * Mathf.Atan(Mathf.Tan(f * Mathf.Deg2Rad * 0.5f) / _camera.aspect) * Mathf.Rad2Deg;
    _camera.fieldOfView = f;
}
\$\endgroup\$
1
  • \$\begingroup\$ Looks mathematically accurate to me. \$\endgroup\$
    – Weckar E.
    Commented Nov 29, 2020 at 9:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .