Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Should platformers have a fixed aspect ratio?

Discussion in 'General Discussion' started by jaaka770, Oct 19, 2023.

  1. jaaka770

    jaaka770

    Joined:
    Sep 4, 2023
    Posts:
    5
    Hi!
    I'm in the process of making my first game which happens to be a platformer. Today I realized that the game is by default built with free aspect ratio which makes it possible to reveal the entire map by resizing the game window. I was therefore wondering if it is general practise to have a fixed aspect ratio in platformers to prevent this "exploit".
    Thanks!
     
  2. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,441
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,535
    Yes, there are plenty of games that assume 16:9 and if you have 16:10 or something they add black bars at the top and bottom.

    Expect people with 21:9 monitors to complain though.
     
  4. roxter08

    roxter08

    Joined:
    May 3, 2019
    Posts:
    4
    As @Cornysam mentioned, it depends on the platform that you are targeting.
    Usually when we are making for mobile platform we try to make sure that the level properly covers the following 3 resolutions

    21:9
    16:9
    4:3
     
  5. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,237
    I won't complain, I just need the extra width for unity! :D
     
  6. TomTheMan59

    TomTheMan59

    Joined:
    Mar 8, 2021
    Posts:
    349
    Don’t make it the same aspect. Just always set the orthographic size to the same width or height depending on your game. This way on any device, they will always see either the same distance in width or height.
     
  7. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,027
    If this is a 2D platformer, then YES, you should mandate an aspect ratio.

    The easiest and most reliable way to do this is by making a script to adjust the viewport rect of the main camera. But it is still not 100% foolproof because it needs to be updated any time someone changes the resolution, and I'm not even sure how to get that to handle someone resizing the window in windowed mode.

    They will complain less about having black bars on the side than they will about being completely unable to see the platforms you are trying to jump to because they were cut off the screen.
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,774
    I keep forgetting if they work right but aren't Screen.width and Screen.height supposed to report windowed res?
     
  9. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,027
    You know, I might be remembering wrong; maybe you can't even change the size of a window by dragging it around. I haven't played with that in so long...