How to better Scale Viewbobbing Speed and intensity

Heyy, I was wondering if someone knows any better formula for the scaling on the viewbob intensity and speed based on the current WalkSpeed of the character , Because currently at high speeds, the viewbobbing doesn’t seems to be that noticeable (except the one modifying the X axis (angles) which is kinda crazy ), so if there’s a better way to adjust the Angles to be less noticeable on higher speeds or just be in resonance with the Y axis viewbobbing, i would like toknow

Also, i am using this spring module

task.wait(.1)
local players = game:GetService("Players")
local localplayer = players.LocalPlayer
local character = localplayer.Character or localplayer.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")
local Hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Camera = workspace.CurrentCamera
local Spring = require(ReplicatedStorage.Libraries:WaitForChild("Spring"))
local abs = math.abs
local sin = math.sin
local cos = math.cos
local settings_ = {
	1.25, 8, 65, 0, 0, 0
}
-- SPRINGS --
local CurrentSpring;
CurrentSpring = Spring.new(table.unpack(settings_)) -- 11 damp
CurrentSpring:SetVelocity(1.5)
local springX = Spring.new(table.unpack(settings_))
springX:SetVelocity(1.5)
-----------------------
RunService:BindToRenderStep("CameraBobble", Enum.RenderPriority.Camera.Value, function(delta)
	local currentTime = tick()
	local RootVelocity = math.round(Vector3.new(HRP.AssemblyLinearVelocity.X, 0, HRP.AssemblyLinearVelocity.Z).Magnitude)
	
	-- FORMULA --
	local Walk_Y = abs(sin(currentTime * (RootVelocity/2.71))) * .7 -- I've been experimenting with these but i can't seem to find a good setting
	local Walk_X = cos(tick() * (RootVelocity/2.71)) * .6
	--
	
	-- IDLE FORMULA SOON... --
	local Breathing_Y
	local Breathing_X
	--
	
	if Hum.MoveDirection.Magnitude <= 0 then
		springX:SetGoal(0)
		CurrentSpring:SetGoal(0)
	elseif Hum.MoveDirection.Magnitude > 0 then
		CurrentSpring:SetGoal(Walk_Y * .90)
		springX:SetGoal(Walk_X * 1.5)
	end
	
	Camera.CFrame *= CFrame.new(0, CurrentSpring.Offset, 0) * CFrame.Angles(0, 0, math.rad(springX.Offset))
	
	--Camera.CFrame *= CFrame.new(0, Walk_Y * .80, 0)-- * CFrame.Angles(0, 0, math.rad(Walk_X * 1.5))
end)

How it looks right now :

Try doing something similar to what I recommended in this post:

You need a spring that has a range from [-1, 1], then use the Offset of the spring multiplied by the max offset you need the bobbing for. You can also use the Velocity and Acceleration of the spring to do this utilizing a change in time dt.

Edit: Instead of changing the camera’s angle (as seen in the post), you would change the camera’s position offset.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.