Force a fixed aspect ratio on your games!

Ever wanted your Roblox game displayed in the same aspect ratio for all users? It’s an understandable concern. Sometimes you only want certain information displayed with the camera and having to deal with different aspect ratios basically makes it impossible.
For example, look at how this scene looks.


Looks great in the intended 16:9 format, however you get something less wide than that and…

…key visual information is cut off!
Similarly, a user with a screen that is too wide will get MORE visual information than is intended.

Well, I have a solution. I was asking about this in Scripting Support and got a great response from ThanksRoBama.

This response is very useful in its own right, but I decided to build on it make it a bit more modular and user-friendly so this useful functionality doesn’t get buried.

DOWNLOAD
Forced Aspect Ratio Demo.rbxl (20.8 KB)

HOW TO USE
I’ve pretty much made this as simple to use as possible. In the StarterGui of the place is a ScreenGui with everything you need in it. If you intend to force a 16:9 aspect ratio with the standard field of view (70) you should just be able to throw this into the StarterGui of whatever place you want and it will work just like that.

However, I have included additional support for those who want to use different aspect ratios or a different field of view.
Instructions on how to do this are included in the comments of the script.

GALLERY
Wider than intended aspect ratio:

Thinner than intended aspect ratio:

Enjoy!

34 Likes

Defining a min and max ratio might also be helpful. Some cases I would not like to reveal too much information, but also not letterbox things unless I absolutely have to.

3 Likes

For some reason this is not working for me
I did as the instructions said, I ran it in an emulator at 1920x1080 which is 16.9
It gave me some values, and I put it in the code.

So this is what I get for full screen

When I press F11, to get a windowed screen, it looks like this…

This is still accurate, you can see how the door at the left is just at the edge.
Even when I shrink the screen things are ok

But if I try to resize my screen, its gets off

However, its only if the vertical is changed, not so much the horizontal

1 Like

Not sure I understand what your problem is. It appears to be maintaining a 16:9 aspect ratio in all of those screenshots.

In the 4th picture when the screen is more 1:1 or any version where the screen is more vertical than horizontal, the camera becomes more ‘zoomed in’ to where you can not see the building or the white blocks.

Could this be used to offset the entire render window for use with a user interface?

Oh you’re right. Must be a bug in my implementation. I don’t have plans to update this unless a new project comes up where I need it, so if you find a fix please include it in this thread.

Couldn’t you just put the user interface inside the render window?

It’s not a bug in your code, its a ROBLOX limitation.

The Camera.FieldOfView property caps its FieldOfView Angle to 120. Once the length of the horizontal axis is too small, the script calculates a horizontal angle that is beyond 120 which is why the screen looks “zoomed in”. Roblox’s justification for the 120 degrees FOV limit is it may be disorientating, which I do understand.

There are posts out there that can go beyond that like this one but imo it is too much work for to fix this as most players on PC don’t play games on a tiny window.