I have some gui for my game that is made of surface gui. In studio, it looks perfect on my screen, but then when I play the game, some of the gui is cut off. Does anybody know how to fix this?
STUDIO
GAME
I have some gui for my game that is made of surface gui. In studio, it looks perfect on my screen, but then when I play the game, some of the gui is cut off. Does anybody know how to fix this?
STUDIO
Try messing with the camera position.
This’s because of your viewport aspect ratio in studio. It’s diffirent than that one you have while playing. Even if you will look at images:
Ok, is there a way I can manipulate the position based on this size?
Yes, you can do this, if you will use ScreenGui, you will receive size of screen in pixels. And after, you need find Aspect ratio with this data, and then use some furmula (idk which one, make it yourself) to calculate, where camera should be.
You can divide the width of the screen by the height of the screen. For example, if the screen size is 1920x1080, the aspect ratio would be 16:9.
Once you have the aspect ratio, you can use it to calculate the size and position of your camera. One easy way to do this is to set the fov property of the camera based on the aspect ratio I guess
local aspectRatio = workspace.CurrentCamera.ViewportSize.X / workspace.CurrentCamera.ViewportSize.Y
local fov = math.atan(math.tan(math.rad(workspace.CurrentCamera.FieldOfView) / 2) * aspectRatio) * 2
workspace.CurrentCamera.FieldOfView = math.deg(fov)
Thank you inventor and cozidatel. inventor, could you explain to me how you came up with this formula though?
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.