In Desmos, I made a simple skewed sin wave for the view model to follow for a more realistic bobble. For some reason though, the frequency(f) isn’t translating to the game properly. I temporarily disabled the Y-axis for a better idea.
Code (sway is earlier in the function and I don’t want to make you have to find the lines yourself):
local a = -.5
local f = 5
local x = 1
local now = os.clock()
local vel = root.AssemblyLinearVelocity
local bobX = math.sin(f*x+a*math.sin(f*x)*now) / 25
local bobY = math.cos(4*now) / 30
if vel.Magnitude > 0 then
local s = math.min(1, vel.Magnitude / hum.WalkSpeed)
local calc = CFrame.Angles(bobX*bobMult*s, 0, 0) --bobY*bobMult*s
bobble = bobble:Lerp(calc, .1)
vm.CameraBone.CFrame = vm.CameraBone.CFrame * bobble * sway
else
vm.CameraBone.CFrame = vm.CameraBone.CFrame * .75 * sway
end
Video:
Any help is appreciated!