How do I scale a viewport frame on all devices?

For my game, I want to make it so that a triangle appears far away in a viewport frame on the center of the screen, and then flies closer in on the screen, shifting to the left side. To achieve this, I decided to change the scale of the viewport frame.

This worked, although it only did on only one screen resolution, as it’s offset on other resolutions are changed, which is not how I want it to be. What can I do to fix this?

The base size of the viewport frame is 1 for scale X & Y, 0 for both offsets.

for i = 1, 15 do task.wait(0.1)
	triangleViewport.Size += UDim2.new(-0.05, 0, 0.02, 0)
	print(triangleViewport.Size) -- (-0.05 * 15 = 0.75 | 1 - 0.75 = 0.25) , (0.02 * 15 = 0.3 | 1 + 0.3 = 1.3)
end

Why not make the viewportframe cover the entire screen in the first place and animate the triangle object instead of the frame

(Nevermind just realized this is… stupid… maybe?)

The viewport frame already covers the entire screen. I was also doing this before, someone recommended me to do what I am doing now, but disappeared off the post after I told them it wasn’t working.

It’s probably because this became more of a UI-Issue than a programming problem.

I think i know the Issue, it’s the ViewportFrame… the Object, doesn’t “stretch”, if you get what i mean… Basically, the Size of the Object will stay Consistent as a Box, like for example

If the ViewportFrame size is X=20 and Y=20
Then the Object size will obviously look “normal” or “even” as the ViewportFrame is a perfect box

But if the ViewportFrame size is X=30 and Y=20, the Object will still display as if it’s in a perfect box like X=30 Y=30

Basically, how the Objects are displayed in a ViewportFrame, cannot be stretched like an ImageLabel…

So then you think I can use some math to change the dimensions of the triangle instead of the viewport frame so that it lines up on every resolution?

You can try, but that’s a bit too much work, i would just recommend you to use a Triangle ImageLabel

I already am actually, but the 3D triangle was supposed to fly in and explode, and

that gave me a new idea, I’m not gonna use the triangle anymore tho

1 Like

I know this MAY be a bit late, but please, use UIAspectRatioConstraint to fix this.