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 andylatham · Mar 05, 2015 at 05:24 PM · cameraresolutionplatformeraspect-ratioorthographic camera

Phantom camera translation when trying to set screen size

Hi, I'm making a 2D pixel-art-based platformer and I'm trying to make it look as close to a Super Nintendo game as Unity will allow me to.

The game is shaping up well, but I'm having trouble getting the resolution correct without distorting the graphics.

Super Nintendo games tended to have a resolution of 256 x 224 pixels, and I would like to have my game render at this resolution, but display magnified 2x in a window of size 512 x 448 pixels.

First of all, my graphics are displayed at 1 pixel per unit, as I felt that this would make it easy for me to move elements around one whole pixel at a time.

Secondly, my player settings show a resolution of 256 x 224.

I have put this code in my camera script:

 camera.aspect = 512 / 448;
 Screen.SetResolution(512, 448, false);
 Camera.main.orthographicSize = Screen.height/4;

This results in a window of the desired size (512 x 448), and my graphics appear to be in the correct places, but they are distorted. Some pixels are stretched slightly horitontally.

If I comment out the aspect ratio line from the code, the pixels display perfectly, but the camera is translated by 20 pixels to the left compared with how it appears in Unity's game view (with the game view set to the resolution in player settings).

Anyone know how to achieve what I'm trying for? I feel I'm close, but need a bit of help.

Thanks!

EDIT: The 20 pixel offset can be ignored, I think that is coming from a calculation involving the camera's position.

I can now achieve the result I want when building, but when I press play in the game view, the view stays the size of the smaller resolution, while the graphics within it scale up to twice their size (as they would be in the doubled-resolution build).

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

Answer by andylatham · Mar 05, 2015 at 04:30 PM

I solved this myself.

I just had to change the player settings resolution to 512 x 488, leaving the aspect ratio code disabled. The 20 pixel shift was a result of a camera position calculation that needed altering for the new resolution.

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

Keep Aspect ratio/Letterbox and maintain pixel perfection 0 Answers

Camera horizontal distortion? 1 Answer

Camera viewport should be square and pixel-perfect, regardless of player aspect ratio. 0 Answers

4:3 aspect ratio 0 Answers

How to adjust desired camera size for all aspect ratios without having black edges? 0 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