# FOV Based On Character's Speed

1. What do you want to achieve?
Im Trying To Make It So The Faster You Move The Higher Fov
2. What is the issue?
I Believe It Just Shakes Due To The Magnitude Being High Enough To Round It And Than Low Enough To Not Round It
3. What solutions have you tried so far?
I Couldn’t Think Of Any After Adding Rounding To It
``````local distancechange = (character.HumanoidRootPart.Position-previous).Magnitude
local fov = game.Workspace.CurrentCamera.FieldOfView - fovrequired
fovrequired = math.floor(distancechange + 0.5)
game.Workspace.CurrentCamera.FieldOfView = fov
game.Workspace.CurrentCamera.FieldOfView += fovrequired
``````
2 Likes

You can just get the velocity of the HumanoidRootPart for the current speed. I’m going to also lerp the values so that it doesn’t feel unnatural (or change values too fast).

``````local PS = game:GetService("Players")
local RNS = game:GetService("RunService")

local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local HRP: BasePart = char:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
local divisor = 5 -- the dampening of the dynamic fov
local lastVelocity = HRP.AssemblyLinearVelocity.Magnitude / divisor
local defFov = 70

local function Lerp(a, b, t)
return a + (b - a) * t
end

RNS.RenderStepped:Connect(function()
camera.FieldOfView = defFov + Lerp(lastVelocity, HRP.AssemblyLinearVelocity.Magnitude / divisor, .25)
lastVelocity = camera.FieldOfView - defFov
end)
``````

8 Likes