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 * 10) * .35
local bobbleY = math.abs(math.sin(currentTime * 10)) * .35
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .25)
else -- we are not walking
humanoid.CameraOffset = humanoid.CameraOffset * .75
end
How can you use :Lerp() to interpolate a camera’s CFrame? If you do a for loop, the camera will force you into that position until the for loop is done.
You could use game:GetService("UserInputService"):GetMouseDelta() to find the change in pixels with the mouse. That way you can add mobile support and change the tilt depending on the speed they move.
local cam = workspace.CurrentCamera
local cf = cam.CFrame
local setcf -- cframe value to lerp the cf variable to
local t = 0.2 -- how long the lerp interpolation is
local runservice = game:GetService("RunService")
runservice.RenderStepped:Connect(function()
cam.CFrame *= cf:Lerp(setcf, t)
end)
Basically it keeps the original CFrame of the camera, but also offsets it with the “cf” variable; which interpolates from one value to another.
Sorry if it doesn’t work it’s 2 am for me right now I’m bad at explaining things, but I hope this helps