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 homer_3 · Jun 17, 2012 at 09:49 PM · camerascaleorthographic

Relation between Orthographic camera size and object scale?

I have some objects in my game that are intended to be HUD items. When I zoom out with an orthographic camera by changing the orthographicSize property, I don't want my HUD's size to change. So I thought I'd increase the scale of my HUD as I zoomed out. Is there some magic number I can use to set the scale based on the current orthographicSize property?

Comment
Add comment · Show 4
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 pheash · Jun 17, 2012 at 09:56 PM 2
Share

I dont know about the magic number, but you can use multiple cameras and leave the scale alone. just make your HUD camera a child of your main camera. use the culling masks of your hud camera to only show stuff on the HUD layer and the main camera to show everything but the hud. also make sure that the depth of your hud camera is bigger than the main cameras. hope that helps

avatar image homer_3 · Jun 17, 2012 at 10:14 PM 0
Share

I had no idea multiple cameras could be used to create a single view. This sounds like a good solution but I've may have run into an issue.

I've added a 2nd camera and made it a child of the main one. I created a layer called HUD and the 2nd camera only has the HUD layer checked, while the 1st has everything but HUD checked. The main camera's depth is -2 and the HUD camera's depth is -1. When I go into my game, I can only see my HUD. What's odd is I can see objects in the main camera's preview while in the edit mode.

I've also tried not having any culling on the main camera and tell it show show everything. But I still only see the HUD layer.

edit: Ok, I found that I needed to set the Clear Flags in the HUD camera to depth only. This works perfect! Thanks!

avatar image Wolfram · Jun 17, 2012 at 10:22 PM 0
Share

Set the HUD camera's "clear flags" to "Don't Clear".

Note that using two cameras is more expensive than using ony one camera.

avatar image Mizuho · Jun 17, 2012 at 11:24 PM 0
Share

I'm using the camera in my game like this. The relative scales are:

 1 - sphere, cube
 10 - plane
 0.5 - camera (sphere/cube will fill screen at 0.5 orthographic size)

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Wolfram · Jun 17, 2012 at 10:07 PM

Hm? As the documentation page states, the screen height is just camera.orthographicSize*2 world coordinates, it doesn't get much simpler than that. Also, that's not even relevant, since you can use relative scaling. So store your initial orthographicSize size somewhere, and then scale your HUD with orthographicSize/storedSize.

Note unless you also want to shift positions around (which of course also change), keep all your individual HUD objects in an empty GameObject attached to the camera, make sure it has no local transformations except a z position that's larger than your nearClip value, and only scale this object. All children objects will then seem to stay in place, when changing the size.

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

6 People are following this question.

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

Related Questions

Resizing orthographic camera to fit 2d sprite on screen 1 Answer

auto scale camera error when upgrading unity4.3 into 4.5 0 Answers

Keep line renderer width same on screen no matter camera distance 1 Answer

the default camera makes everything look like its moving towards the center? 2 Answers

Orthographic camera's child is not showing up in camera preview or game view 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