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
2
Question by Krummelz · May 26, 2013 at 02:05 PM · camera2d-gameplayorthographic

2D: Camera Size, in Orthographic Projection vs Scale of a Plane

I want to make a 2D game, and I've set the camera up with Orthographic projection. Now I want to add a plane in front of that camera to use as a background for the game. The camera has a size setting, which affects the size of my plane. The plane also has a scale setting, which does the same thing (by the looks of it). These two settings, however, don't seem to work well together. For example, I've set my camera to have a size of 10, and my plane to have a scale of 1 x 1 x 1. This scale makes the camera much larger than what I would like for it to be. I thought if the scale of the plane was the same as the camera size, that the plane would fit perfectly into the camera view. I have a feeling that I have no idea what I'm doing. Could someone please help me out here? 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

2 Replies

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

Answer by Owen-Reynolds · May 26, 2013 at 02:51 PM

"These two settings, however, don't seem to work well together." Yes, but not a big deal.

It's just math. The Ortho camera scale is how far it goes both ways, so a scale of 10 shows you a 20-wide chunk of scene. The basic Unity plane just happens to be 10x10. That's sort of odd, since everything else (cubes, spheres) is 1x1. But most people probably want a big plane for backgrounds, walls or floors.

Just pick a size. If you want to aim at 0-5, set the cam at x=2.5 and Size=2.5. Then do the plane. Since it's size 10, scale by 1/2 to get a width of 5.

For fun, measure things out. Can be handy to make reference cubes (maybe color them red and make them long and thin. Bring them to the sides of what the cam sees and check values (does a Size 5 cam really see from -5 to 5?) Can measure the plane width using them.

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
8

Answer by robertbu · May 26, 2013 at 02:53 PM

'Orthographic Size' is half of the vertical size of the camera view. You can get the half horizontal size by multiplying the vertical size by Screen.width/Screen.height. So:

 var verticalSize   = Camera.main.orthographicSize * 2.0;
 var horizontalSize = verticalSize * Screen.width / Screen.height;

Object size and object scale are not the same thing. Scale simply scales up or down whatever the size of the mesh. If you are using the build-in plane, the size in world units with a scale of (1,1,1) is 10 x 10.

For experimentation, make sure the camera 'Y' is set to 0. Place a cube at the origin and size it to be twice the Orthographic Size. Note the build-in cube does have a size of 1x1x1 when the scale is (1,1,1).

You might also be interested in the CreatePlane script. It allows you to create a plane with a base size of 1x1 and also with a vertical presentation when the rotation is (0,0,0).

http://wiki.unity3d.com/index.php?title=CreatePlane

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

14 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

Related Questions

Orthographic Camera Size? 3 Answers

Dynamic shadows in orthographic camera. 2 Answers

Implementing Camera bounds proportionally to its ortographic size 0 Answers

How to make WorldToScreenPoint work with an orthographic camera? 0 Answers

Best Setting Size Orthographic 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