Shifting the camera's position when a GUI sidebar is showing

I’m trying to shift the camera to focus on the character (in the Scriptable setting) while a certain GUI sidebar is showing on the screen. I’m not really sure how to calculate the position that the camera would be focused on, however. I’d obviously start at the HumanoidRootPart, but I don’t really have a way to convert the UDim2 (he UDim, actually, since I’m talking about one dimension) of the GUI into an offset in studs for usage in Vector3 or CFrame.

Is there an easy way to calculate this? I was thinking of if I can somehow get the position right where the camera cuts off at and then somehow interpolate the center/edge of the camera with the percentage of the screen that the GUI takes up, but I am not aware of any property or function that gives me such details.

Try to use Camera.Subject, it’s like when you select an object and press F (When editing). :smiley:

I’m not referring to setting the CameraSubject, but instead trying to figure out if there was some way to shift the camera away from the “camera subject” – in other words, I’d be doing CameraType = Scriptable and Camera.CFrame = Target.CFrame * CFrame.new(OFFSET) where OFFSET would be some sort of result where size of the UI in 2D space (pixels, etc.) is converted to an equivalent value in studs.

first get the camera CFrame then make a variable which moves it away from the player by adding a CFrame/Vector3 to it, then use tween and move it away from the player.
Note you can’t really change the UI into studs, as far as I know.

I am trying to figure this part out; “getting the camera CFrame” and tweening is easy.
In other games as well I have seen people figure this out so I definitely know it is somehow possible.

Couldn’t you just do Camera.CFrame

I appreciate you trying to help but no it is not as simple as “[doing] Camera.CFrame.”

1 Like