How to calculate where to position the camera based on character and screen size

How can I calculate where to position the camera based on the character size but more importantly screen size

My current code uses the same position for all the characters and screen sizes here’s the results;

Code
Camera.CameraType = Enum.CameraType.Scriptable
Camera.FieldOfView = 60
Camera.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(180),0) * CFrame_New(2.5, .5, 6.5)--workspace.CameraPart.CFrame

Too much to the right

Too low and the bunny ears are cut off

A bit too much to the left

The character is too big and the wings are cut off


I hope the images provided explains what I am trying to achieve, feel free to ask questions.

You might be able to use GetExtentsSize to improve how far to zoom out.

2 Likes

Thank you! :+1:


local ExtentsSize = Cha:GetExtentsSize()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.FieldOfView = 60
Camera.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(180),0) * CFrame_New(2.5+(ExtentsSize.X/10), .5, 6.5+(ExtentsSize.Z/2))

Great now I need a good ratio and some math stuff + figure out how to calculate for screen sizes.

1 Like