How do I position a triangle depending on the viewportsize?

For my game, I want to make it so that a triangle appears far away in a viewport frame and then flies closer in on the screen, shifting to the left side. To achieve this, I assumed it is necessary to scale the triangle’s height off of the player’s screen resolution, and utilize the properties of camera.ViewportSize to adjust the triangle’s position accordingly.

Like these would not have the same triangle size and position if they were on the far left of the screen. So what do I do?

1 Like

You don’t actually have to do this. You can think of the ViewportFrame as showing you an image, so if you change the size of the ViewportFrame, the image will be stretched/scaled accordingly

Test it out, studio has a built-in device emulator, compare how it looks across different screen sizes without adjusting the size of the triangle

I suggest moving the ViewportFrame itself rather than the objects within it, if that isn’t needed for your effect

I can’t find the “built-in device emulator”, but comparing it by changing my resolution through the Studio UI showed that the triangle has an offset on other resolutions. What can I do?

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

Can anyone help me? I still can’t figure this out.