Clamp Viewport Aspect Ratio in Shipping Build

Does anyone know a way to clamp the viewport’s aspect ratio on a Windows shipping build?

Would like to prevent the player from increasing Y:X to anything greater than 1:1 (i.e. prevent Y resolution being larger than X).

I know there is a setting in Project Settings called “Allow Window Resize”, which can be unchecked, but I don’t want to prevent any resizing, just want to clamp the aspect ratio.

There is also a console command (r.setRes) which changes viewport resolution and can even be called from a blueprint. I can check the aspect ratio each time the screen resolution is changed, and use this console command to change the viewport dimensions. However my understanding is console commands don’t work with shipping builds (and this solution seems a little hacky anyway)

Anyone know a solution? Something obvious I’m missing?

1 Like

Console command in shipping builds is not hacky at all :slight_smile:

They’re used often.

It might not be with a console command, but I think you do just need to check and correct the screen size. There are blueprint nodes for that

Brilliant! Thanks!

There were a couple differences between the linked video and what worked for me (possibly due to differences in engine version, I’m using 5.5.1):

  • “Apply Settings” is no longer required after “Apply Resolution Settings”
  • Before “Apply Resolution Settings”, I had to add a “Set Fullscreen Mode” node and set it to Windowed. Otherwise, it defaults to full screen.

Here’s a screenshot of my test setup. Works like a charm.

Thanks as always @ClockworkOcean !

1 Like

:star_struck: