I’ve been using this script (someone made on forums) to create a 1st person bobble effect, and it is working.
The problem is I don’t know how to change the speed of the lerping. My understanding is that lerping goes (cameraOffset) from 1 place to another place in a certain timeframe. The parameters don’t seem to change the speed, but rather the distance.
So my question is: How and if it is even possible to change the speed of the lerp.
local RunService = game:GetService("RunService")
local playerModel = script.Parent
local humanoid = playerModel:WaitForChild("Humanoid")
local function updateBobbleEffect()
local now = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- Are we walking?
local velocity = humanoid.RootPart.Velocity
local bobble_X = math.cos(now * 9) / 4
local bobble_Y = math.abs(math.sin(now * 12)) / 4
local bobble = Vector3.new(bobble_X,bobble_Y,0) * math.min(1, velocity.Magnitude / humanoid.WalkSpeed)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble,(1/25))
else
humanoid.CameraOffset = humanoid.CameraOffset * 0.75
end
end
RunService.RenderStepped:Connect(updateBobbleEffect)