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 Kensharma · Mar 05, 2014 at 01:30 AM · camera2dscalingorthographicaspectratio

2D Camera Question: Pixel Perfect W/O Cutting Bottom Edges

Hey there Unity Community.

This is my first thread here and my first project in the Unity engine.

I am designing a 2D endless runner at the moment and I have run into some difficulties in terms of camera scaling. At the beginning, I simply slapped on a script that took the screen height / 100 / 2 and used that as the camera scale. This created pixel perfect image quality.

However, I have now realized that this script alone is simply not going to do the trick.

Whilst it does make the game look sharp at any aspect ratio, etc, I need to figure out a way to maintain this crisp quality whilst preventing the vertical axis from scaling to the point that you can now see under the floor of the platform.

This means that I need to either:

a) Modify the script so that the game will scale the same but the vertical axis will never start below my platform.

or

b) Modify the script so that the game will be pixel perfect (or at least close to it) but only scale the horizontal axis (the horizontal axis doesn't effect gameplay substantially for my game style).

Here is the script I am currently using:

 // set the camera to the correct orthographic size
 // (so scene pixels are 1:1)
 s_baseOrthographicSize = Screen.height / 100.0f / 2.0f;
 Camera.main.orthographicSize = s_baseO

How can this be modified to do either of the above?

Thanks so much for your help!

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
0

Answer by Kensharma · Mar 05, 2014 at 04:58 AM

To elaborate on method 1 if I didn't explain this well enough;

Method 1 essentially means that the camera will adjust itself so that the bottom of the screen is always at a certain point (so that you always see the bottom being the egde of the platforms) and add the ortho size from there.

E.X. My platform starts at y -1 and ends at y 2 (height). The camera needs to start at -1 (height) and then add the screen height / 100 / 2 to keep it pixel perfect.

If you have any other methods I could use (I heard about scaling by multiplying size of objects, would love to know how that works) feel free to suggest those aswell.

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

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

Set Orthographic Camera To Always Have Y Coordinate Start At Set Position 0 Answers

Orthographic camera movement clamping 1 Answer

Making a camera semi-orthographic 2 Answers

parallax scrolling using orthographic camera 1 Answer

Dynamic Orthagraphic Camera Zoom 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