So i made a FOV changer that changes your FOV every frame.
local LocalPlayer = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
-- Set the minimum and maximum FOV values
local minFOV = 70
local maxFOV = 120
game:GetService("RunService").Heartbeat:Connect(function()
-- Calculate the current velocity of the character
local velocity = LocalPlayer.Character:WaitForChild("HumanoidRootPart").Velocity
-- Calculate the target FOV based on the velocity
local targetFOV = minFOV + (maxFOV - minFOV) * (velocity.magnitude / 50)
-- Create a tween to smoothly transition the FOV to the target value
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = tweenService:Create(camera, tweenInfo, {FieldOfView = targetFOV}):Play()
end)
My problem is simple, when jumping, your velocity goes up, there is a moment when your velocity is low (when you start falling from the jump), and when falling your velocity goes up again. So when jumping it looks bad because the fov gets lower when halfway done with the jump. I want to fix that. Because it doesn’t look very good.
Honestly speaking, this is not what i was searching for. It wouldn’t be good when you start running and only half a second later, your fov start changing.
local LocalPlayer = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local tweenService = game:GetService("TweenService")
local minFOV = 70
local maxFOV = 120
local mostVelocity = Vector3.new()
game:GetService("RunService").Heartbeat:Connect(function()
local hum = LocalPlayer.Character:WaitForChild("Humanoid")
local velocity = LocalPlayer.Character:WaitForChild("HumanoidRootPart").Velocity
if hum:GetState() ~= Enum.HumanoidStateType.Freefall or velocity.Magnitude > mostVelocity.Magnitude then
mostVelocity = velocity
end
local targetFOV = minFOV + (maxFOV - minFOV) * (mostVelocity.magnitude / 50)
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local tween = tweenService:Create(camera, tweenInfo, {FieldOfView = targetFOV}):Play()
end)