Hello.
I seem to have a little problem with this script I have. it’s a camera bob script, but it feels kinda wonky. Everytime I let go of the W key, it just snaps.
VIDEO:
Here is the code:
local runService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
function updateBobbleEffect()
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- we are walking
local bobbleX = math.cos(currentTime * 4) * .35
local bobbleY = math.abs(math.sin(currentTime * 4)) * .35
local bobble = Vector3.new(bobbleX, bobbleY, -0.45)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25)
else -- we are not walking
humanoid.CameraOffset = Vector3.new(0, 0, -0.5)
humanoid.CameraOffset = humanoid.CameraOffset * .75
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
What could I do to fix it?