I made a nice camera bobbing script, but I have one last issue
local RS = game:GetService('RunService')
function updatebob(deltatime)
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character.Humanoid
local Camera = workspace.CurrentCamera
if Humanoid.MoveDirection.Magnitude > 0 then
local OFFSET_BOBBLE_Y = (math.sin(deltatime * 8) * 3)
local CAMERA_BOBBLE_Z = math.sin(deltatime * 8) * 0.6
local CAMERA_BOBBLE_Y = math.sin(deltatime * 8) * 0.2
local RESULT_OFFSET = Vector3.new(0,OFFSET_BOBBLE_Y,0)
local RESULT_CFRAME = CFrame.Angles(CAMERA_BOBBLE_Y,0,CAMERA_BOBBLE_Z)
Camera.CFrame = Camera.CFrame:Lerp(Camera.CFrame * RESULT_CFRAME, .05)
Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(RESULT_OFFSET, .05)
else
Humanoid.CameraOffset = Humanoid.CameraOffset:Lerp(Vector3.new(0,0,0), .05)
end
end
RS.RenderStepped:Connect(function(dt)
updatebob(tick())
end)
And everything works fine, but the camera bobbing goes a little off:
As you can see the cursor goes off the spawn location (I am not moving my mouse at all)
And it also goes to the Y direction of the camera. Can anyone help me?