This post is a follow-up to my previous post here:
Hey there everyone!
I decided to make this post to my previous problem because of my camera bobble script working wierdly.
local runService = game:GetService("RunService")
local tweenService = game:GetService("TweenService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local camera = workspace.CurrentCamera
local jumpswaygoal = Instance.new("CFrameValue")
function updateBobbleEffect()
if humanoid.FloorMaterial ~= Enum.Material.Air then
local currentTime = tick()
if humanoid.MoveDirection.Magnitude > 0 then -- we are not standing still
if not _G.Sprinting then -- we are walking
local bobbleX = math.cos(currentTime * 5) * .1
local bobbleY = math.abs(math.sin(currentTime * 6)) * .2
local bobbleRotate = math.cos(currentTime * 2) * .1
local bobblePos = Vector3.new(bobbleX, bobbleY, 0)
local bobbleRot = CFrame.new(bobbleRotate, bobbleRotate, bobbleRotate)
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(bobblePos, 0.15)
camera.CFrame = CFrame.new(camera.CFrame.Position) * camera.CFrame.Rotation:Lerp(bobbleRot, 0.15)
elseif _G.Sprinting then -- we are sprinting
humanoid.CameraOffset = humanoid.CameraOffset * 1
local bobbleX = math.cos(currentTime * 7) * .4
local bobbleY = math.abs(math.sin(currentTime * 9)) * .6
local bobble = Vector3.new(bobbleX, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:Lerp(bobble, .25)
end
else
local speed = currentTime * 1
local distance = .15
local bobbleY = math.abs(math.sin(speed)) * distance
local bobble = Vector3.new(0, bobbleY, 0)
humanoid.CameraOffset = humanoid.CameraOffset:lerp(bobble, .2)
end
end
end
runService.RenderStepped:Connect(updateBobbleEffect)
robloxapp-20240726-1713197.wmv (1.6 MB)
What’s happening is that the camera looks at the 0, 0 coordinates like the Dark Souls lock-on system when I walk.
Not sure how to fix this…
Any help is highly appreciated.