Hello! I’m new to and just getting back into scripting and I want to recreate the walking animation from SCP Containment Breach, but I ran into an issue after getting the tilt corrected. Whenever I stop walking, the camera’s position and orientation automatically get reset to its 0, 0, 0 positions, when in reality I would want the Camera’s position to pause right where it is once walking stops.
The video below shows what it looks like.
I’ve dabbled with solutions and searched a bit, but I have yet to find a good answer that was clear enough for me to understand. None of them have worked and I’m not sure where to go from here. Any assistance is appreciated.
(If anything in this post needs to be clarified on I’ll do my best to explain more, this is my first post after all)
Script:
local runService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
function updateBobbleEffect()
local currentTime = tick()
local bobble1 = math.abs(math.cos(currentTime * math.pi * 1.5) * .4)
local bobble2 = math.cos(currentTime * math.pi * -1.5) * .01
if humanoid.MoveDirection.Magnitude > 0 then
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.Angles(0, 0, bobble2)
workspace.CurrentCamera.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(0, bobble1, 0)
end
end
runService.RenderStepped:Connect(updateBobbleEffect)