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 spyshower · Sep 01, 2012 at 05:55 PM · androidaspect ratio

How to adjust a 2.5D game for android for different resolutions

The game I am creating is 2D with 3D camera. From what I understand, I should instantiate every game object in my game based on the aspect ratio and not the resolution, but that doesn't sound good enough in my ears.

Also, I have no idea what to do with the camera.

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 kromenak · Sep 03, 2012 at 09:45 AM

In my experiences, the camera will always fill the available vertical space on the device's screen. You can imagine that the camera view zooms in until it fits snugly in the vertical space of the screen. As a result of this, if a screen is particularly tall and particularly narrow, a lot of the width of view gets cropped at the edges. (If you are making a landscape game, the same principles apply, just the view is really wide).

Both 2D and 3D elements should scale pretty gracefully between different screen sizes. A really high-res screen like on the iPad 3 will cause some graphics to look blurry, but if you design with the highest-res in mind, it should scale down pretty well.

The tricky part is if you want to position a GameObject in the corner of the screen, no matter what the screen size is. To accomplish this, you can use a Camera function:

 Vector3 worldPos = Camera.main.ViewportToWorldPoint(Vector3.zero);

This would give you the world position of the lower-left corner of the screen; Vector3.one would be the top-right corner of the screen. By positioning things this way, you give your game a fluid layout (sort of like a webpage, but the user can never resize the window :P)

Comment
Add comment · Show 4 · 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 spyshower · Sep 09, 2012 at 06:56 PM 0
Share

Thanks for this tip, however, I am having trouble at the initial placement of the camera. For example, let's say I have a room with a door in the center, and the camera is pointing at the door (you can view the whole room). If I choose "Free aspect" in the game window within Unity, everything is ok. But when I choose android 4:3 or 480x800 for example, I only see a small part of the scene, say just the door.

How do I fix that?

avatar image kromenak · Sep 10, 2012 at 05:40 AM 0
Share

I think you'd have to do a bit of coding the camera's properties to get this effect. You could either change the Camera's Z position depending on the screen width, or you can adjust the field of view/camera size depending on the screen width.

For example, I think with a bit of trigonometry, you can calculate how far back the camera would need to be on a device-by-device basis. If you know the world positions of the farthest left and farthest right you'd need to view on the screen, you could then calculate how far back the camera would need to be based on the field of view.

 #---------#
  \       /
   \     /
    \   /
     \A/
      C

Where the # signs are furthest left/right, A is field of view, C is camera.

I'm not aware of an easier way.

avatar image spyshower · Sep 10, 2012 at 07:32 AM 0
Share

That's exactly what I had in $$anonymous$$d: to change camera's Z position based on screen width.

Regarding the height of the screen, is it a good idea to play with the camera's size/field of view (not sure which one), in order to make it fit in the screen?

avatar image kromenak · Sep 12, 2012 at 03:54 AM 0
Share

Camera size is used with orthographic cameras, whereas field of view applies to perspective cameras.

As for whether to use Z positioning or changing the field of view, I'd just experiment with changing the size of the game window and adjusting the camera settings. I could imagine that changing the field of view causes some sort of distortion, but I'm not sure.

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

10 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

Related Questions

Particle System appears wildly different in editor, web player, android 1 Answer

OrthographicSize on Android changes from Start to Update? 0 Answers

Aspect Ratio problem 0 Answers

Can't run a game widescreen/Landscape , its portrait always. 1 Answer

Android - Normalize touch position based on mobile screen size 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