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
1
Question by NachoDA · Mar 07, 2015 at 07:54 AM · cameratrigonometryfield of view

Calculating the players view with the camera

Hi,

I'm working on a 2D scroll video game. It's a shooter with a dynamic camera depending on wich weapon the player take.

alt text

RED LINE: Player view == Weapon distance. YELLOW LINE: Distance Player to Camera. The angle is taken from the Field of View Camera value (originally is 42).

I want to calculate the Distance Player to Camera depending on the weapon distance or vice versa, it's the same problem. And that's basic trigonometry. To take the weapon distance: **b = tg(21) 10*; b = 3.83 units.

The problem is that this value disagrees with the test I made:

TEST 1: I created a basic box and scale it to fill the red line distance and it measured more than 6 units.

TEST 2: In case I was wrong with the first test, I draw a vector from the player in the red line direction with distance 3.83 units and it was as short as the numbers are telling me.

What I'm doing wrong?

Thanks!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by CHPedersen · Mar 07, 2015 at 07:58 AM

Great question, with good illustration.

What you're doing wrong is that you're using half the camera's field of view to arrive at the 21 degrees. But the field of view is the vertical field of view, not the horizontal. So that angle is not equal to 42/2 = 21.

You can convert the vertical field to view to the horizontal with the aspect ratio and a little bit of trig, please see the replies in this forum post:

http://forum.unity3d.com/threads/how-to-calculate-horizontal-field-of-view.16114/

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

FOV script does not change camera FOV on executable, but it does in the unity playtest. 0 Answers

Is it possible to show only a part of what camera sees? 1 Answer

How to make camera position relative to a specific target. 1 Answer

Hide gameObjects which are blocking camera's view 1 Answer

Trigger when something enters the Field of View of the Camera 1 Answer


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