• 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 rageingnonsense · Jun 01, 2015 at 05:15 PM · projectororthographicaspect-ratio

Calculating projector aspect ratio and orthgraphic size based on width/height

I am trying to add some area selection functionality to my game. To do this, I have added a game object with an orthographic projector to my scene. It looks nice, but I am confused by how to adjust the width/height (or depth, depending on how you look at it).

Adjusting the aspect ratio, and the orthographic size gives me what I need to map the selection area to a width/height, but I do not know how to do the conversion.

For instance, lets say the player selects a 5x7 area on the play grid (all grid points are a size of 1). how do I convert 5x7 into aspect ratio AND orthographic size such that a 5x7 grid area is shown as selected.

Aspect ratio is easy; just width / height. However, orthographic size expands in all directions. As such, it is not as simple as just calculating aspect ratio for the width, and setting orthographic size as the height.

Some written examples of aspect ratio size differences, and the effect on the projection:

  • aspect ratio 1 and ortho size 2: 4x4 area

  • aspect ratio 2 and ortho size 2: 8x4 area

  • aspect ratio 2 and ortho size 1.5: 6x3 area

  • aspect ratio 1.5 and ortho size 1: 3x2 area

  • aspect ratio 0.25 and ortho size 4: 2x8 area

I can't seem to figure out the pattern of ortho size in relation to desired height though. All of these values above were gathered from manually playing with the aspect ratio and size.

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
3
Best Answer

Answer by georgeq · Jun 01, 2015 at 08:20 PM

It is not very clear what you really want, but the orthograhic size tells you how many units (say meters) the camera can see from center to top (or bottom if you like), that is 1/2 of the total visible height, so if your orthographic size is 5 your camera will see 10 in the Y axis (height). to know how much your camera can see in the X axis, just multiply the orthograpic size times aspect ratio. If your camera has an orthographic size of 5 and your aspect ratio is 1.5 then your "horizontal ortographic size" will be 7.5, meaing your camera can see 15 metters in the X axis (width).

Now, if you know this, then you can see a pattern in your data:

 4x4 then x=4 and y=4 so OrthographicSize = y/2 = 2.
 8x4 then x=8 and y=4 so OrthographicSize = y/2 = 2.
 6x3 then x=6 and y=3 so OrthographicSize = y/2 = 1.5.
 3x2 then x=3 and y=2 so OrthographicSize = y/2 = 1.
 2x8 then x=2 and y=8 so OrthographicSize = y/2 = 4.

hope this answers your question.

Comment
Add comment · Show 1 · 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 rageingnonsense · Jun 01, 2015 at 11:00 PM 0
Share

Yes this was the solution. Thank you!

For anyone else who sees this, here is the formula in its essence:

aspect ratio = width/height orthographic size = height / 2

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

Why is the camera aspect ratio broken for the game tab? 0 Answers

OrthographicSize on Android changes from Start to Update? 0 Answers

What is the meaning of 1:1 in unity? 1 Answer

Orthographic projector spills outside of its bounds 1 Answer

Ortho camera viewport setup? 3 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