Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you change field of view based off of screen resolution?

Asked by 7 years ago

I have this code (stolen from wiki, i'm learning i'm learning)

wait(0.001)
script.Disabled = false

local offset = Vector3.new(40,40,40)
local fieldOfView = 25

local player = game.Workspace.Elf
local camera = game.Workspace.CurrentCamera
local runService = game:GetService('RunService')

camera.FieldOfView = fieldOfView

local function onRenderStep()
    local playerPosition = player.Torso.Position
    local cameraPosition = playerPosition + offset
    camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end

runService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, onRenderStep)


game.StarterGui:SetCoreGuiEnabled("All", false)

The problem is that the distance between the camera and player changes per screen resolution. How do I make it so the field of view changes for bigger/smaller screens?

Answer this question