Basically, I am making a single-player story game, and the players are locked in first person. I want the walking to be semi-realistic and so I added camera bob. The only problem is that I don't know how to make the camera bob slower to match the footsteps. I don't know if this helps but the footsteps are half a second apart each. Thank you!
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 -- if you start walking
local bobbleX = math.cos(currentTime * 10) * .25
local bobbleY = math.abs(math.sin(currentTime * 10)) * .25
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25)
else -- if you stop walking
humanoid.CameraOffset = humanoid.CameraOffset * .75
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
