Hello! so, i tried to make a FOV effect system to enhance the feel of my game, here is a little clip of it working
as you can see, for the simple shots, the FOV moves seamlessly, but for the last shot, the charged one, it stutters a bit, and i have no idea why!!!
this is the code that handles the FOV shove
function easeOutCubic(x: number): number
return 1 - math.pow(1 - x, 3);
end
function module.shove(FovIncrease: number, Duration: number?, transitionTime: number?, easing: (number) -> (number)?, transitionEasing: (number) -> (number)?)
local shove: shoveValue = {
FovIncrement = FovIncrease,
StartTime = time(),
Duration = Duration or .6,
Easing = easing or easeOutCubic,
TransitionEasing = transitionEasing or easeOutCubic,
Transition = transitionTime or 0
}
print('Created a shove!')
table.insert(shoves, shove)
end
function module.setFov(newFov: number, TransitionTime: number?)
--TODO
end
module.server.shove = module.shove
game.Players.LocalPlayer.CharacterAdded:Connect(function(character: Model)
currentBaseFOV = defaultFOV
end)
runService.RenderStepped:Connect(function(deltaTime: number)
local camera = workspace.CurrentCamera
camera.FieldOfView = currentBaseFOV
for index, value in ipairs(shoves) do
local shoveStartTime = value.StartTime + value.Transition
local lifetime = time() - shoveStartTime
local transitionProgress = (time() - value.StartTime) / value.Transition
if lifetime > value.Duration then table.remove(shoves, index) continue end
local fovIncrease = if lifetime < 0 then value.TransitionEasing(transitionProgress) else (1 - value.Easing(lifetime / value.Duration))
camera.FieldOfView += fovIncrease * value.FovIncrement
end
end)
and this is what calls the shoving
Base shot
task.defer(function()
local FOVHandler: FOVHandler.server = FOVHandler:from(player)
FOVHandler.shove(30, 2, .05)
end)
Charged shot
local chargeUpDuration = track:GetTimeOfKeyframe('shoot')
FOVHandler.shove(-15, .4, chargeUpDuration + .1)
track:GetMarkerReachedSignal('shoot'):Once(function(...: any)
print('Shot!')
FOVHandler.shove(50, 6, .05)
end)
anyone has any idea on what’s the problem?