Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by sldsmd · Dec 27, 2013 at 08:12 PM · camerafovfieldofview

Is there a way to set the horizontal field of view of a camera?

Thanks in advance.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by hargisss · Mar 04, 2015 at 04:56 PM

I just had the same problem. Drussilla's code is a good approximation, but is not exact. This Javascript code should be precise:

 var hFOV : float = 30;
 
 function FixedUpdate() {
 var hFOVrad : float = hFOV*Mathf.Deg2Rad;
 var camH : float = Mathf.Tan(hFOVrad*.5)/camera.aspect;
 var vFOVrad : float = Mathf.Atan(camH)*2;
 camera.fieldOfView = vFOVrad * Mathf.Rad2Deg;
 }

Simply copy the code to a new javascript and attach it to the camera.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image zerophase · Feb 19, 2016 at 09:11 PM 0
Share

@hargisss Is there anyway to increase the horizontal field of view without distorting the image?

avatar image hargisss zerophase · Feb 19, 2016 at 10:01 PM 0
Share

Hi, zerophase. I'm a little unclear as to what you mean. What are you trying to do specifically?

avatar image zerophase hargisss · Feb 21, 2016 at 02:54 AM 0
Share

@hargisss Thanks for the quick response. I'm making a racing game, and the default viewing angles of the camera limits the peripheral distance seen when in first person. I'm trying to make the camera show cars passing on the left and right side a bit sooner.

This post goes into greater detail on my issue; http://answers.unity3d.com/questions/1144842/adjusting-viewing-angle-without-distortion.html

avatar image
2

Answer by Statement · Dec 27, 2013 at 08:20 PM

You can set the vertical field of view easily (though you asked for the horizontal and I know of no simple setter for that).

I think you can set the vertical field of view to derive the horizontal field of view, or you could possibly look into messing with the cameras projection matrix to customize for your needs.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by drussilla · Nov 12, 2014 at 11:14 PM

To se horizontal field of view for a camera you should create component with following logic:

 camera.fieldOfView = 60 * (16f/9f) / ((float)camera.pixelWidth / camera.pixelHeight);

where 60 is your target field of view value. and 16f/9f - default aspect ration (so the same value for horizontal and vertical field of view give the same image) Here you can find more information.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Camera movement in a 2D? (like angry birds) 1 Answer

Find out if GameObject is in Field of View 2 Answers

Negative results when converting HFOV to VFOV? 1 Answer

Automatically adjust cameras FOV to maintain a perfect 360 coverage with multiple cameras 0 Answers

How to animate zooming in of the camera? 4 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges