Search Unity

Question FOV Completely Shows different values

Discussion in 'Scripting' started by ilmas0, Mar 30, 2023.

  1. ilmas0

    ilmas0

    Joined:
    Jan 5, 2021
    Posts:
    4
    So I was just trying to make smooth FOV transitions between running and walking actions. (I am totally amateur) Then I was started to think inspector FOV output wasn't really look like true. Then I created my own FOV output with Canvas and outputs were totally different. And yes I have only one camera. So is my script wrong? Is it some Unity problems? Can someone explain me and help?

    Thanks for the explanations!

    upload_2023-3-30_21-21-5.png
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Camera fieldOfView is always the Vertical FOV. You have yours set to horizontal.
     
    Bunny83 likes this.
  3. ilmas0

    ilmas0

    Joined:
    Jan 5, 2021
    Posts:
    4
    Thank you for your response!

    It actually worked now. And what about horizontal fov? can i change that through script?
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Nope, Unity doesn't really have a horizontal fov mode. When the aspect ratio changes, it always keeps the vertical fov constant and the horizontal one changes.

    If you want constant horizontal fov regardless of aspect ratio you need to do the calculations yourself to convert to vertical fov and set that all the time.

    These may help:

    https://docs.unity3d.com/ScriptReference/Camera.HorizontalToVerticalFieldOfView.html

    https://docs.unity3d.com/ScriptReference/Camera.VerticalToHorizontalFieldOfView.html
     
    orionsyndrome, Bunny83 and ilmas0 like this.