The code here works perfectly fine, however as you can see in the attached video, when stopping the head bobbing also stops immediately and I find this really jarring. https://gyazo.com/16bd416a9ceb67b09bb668e23599ea75
The code
local function onUpdate() -- Runservice
-- Camsbobbing
if Humanoid.MoveDirection.Magnitude > 0 then -- If walking
local currentCF = workspace.CurrentCamera.CFrame
local x = math.cos(tick() * Walkspeed) * WalkpowerX
local y = math.abs(math.sin(tick() * Walkspeed)) * WalkpowerY
local cf = currentCF * CFrame.new(x, y, 0)
Camera.CFrame = cf
else -- If standing still
local currentCF = workspace.CurrentCamera.CFrame
local y = math.abs(math.sin(tick() * 1)) * 0.5
local cf = currentCF * CFrame.new(0, y, 0)
Camera.CFrame = cf
end
end
When the camera stops moving you are instantaneously setting the CFrame to the idle position. If you want to transition smoother since it’s RunService use CFrame lerping from the current camera CFrame towards this goal CFrame.
This only seems to “lessen” the bobbing. I could replicate this just by doing:
local WalkpowerY = 0.5
if walking then
local y = math.abs(math.sin(tick() * Walkspeed)) * WalkpowerY
else
local y = math.abs(math.sin(tick() * 1)) * 0.5
end
What I want to know is how to retain the “power” of the camera bobbing in the video while smoothly stopping the camera bobbing when the player stops