A while ago I was asking for help with this script which is derived from a REALLY old free model, I needed help to make it non-fps dependant.
Eventually, with some help and a 30-something reply thread, I achieved it, and I have decided to open-source it!
TOOLBOX LINK:
Notes
The code is atrocious since, well, it is derived from a free model, but it works, I promise.
Setup is straightforward, just drop this into StarterCharacterScripts and you’re done! The customizable things are:
the damping (basically the strength of the bobbing), you can swap it with a whole number or change the division value; by default, it depends on the player’s walk speed divided by 2
On line 46, you can change the 102 * (30*step) to different numbers, it changes the speed of the bobbing, but I recommend you keep the 102 above 60 or 50
So, what exactly do I mean by “non-fps dependant”?
Basically, I made it work with FPS unlockers, that’s it
SHOWCASE VIDEO
Sorry it took me 6 months to make one
Warning: has swearing in it
Thanks for getting this far, I hope this is useful to someone!
while true do
wait();
if game.Players.LocalPlayer.Character then
break;
end;
end;
camera = game.Workspace.CurrentCamera;
character = game.Players.LocalPlayer.Character;
Z = 0;
damping = character.Humanoid.WalkSpeed / 3; --[[This is pretty much the strength of the camera bobbing
you are free to change the character.Humanoid.WalkSpeed / 2 to either a whole number or change the division]]--
PI = 3.1415926;
tick = PI / 2;
running = false;
strafing = false;
IsMoving = false;
character.Humanoid.Strafing:connect(function(p1)
strafing = p1;
end);
character.Humanoid.Jumping:connect(function()
running = false;
end);
character.Humanoid.Swimming:connect(function()
running = false;
end);
character.Humanoid.Running:connect(function(p2)
if p2 > 0.1 then
running = true;
return;
end;
running = false;
end);
character.Humanoid.Died:connect(function()
running = false;
end);
character.Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if character.Humanoid.MoveDirection.Magnitude == 0 then
IsMoving = false
else
IsMoving = true
end
end)
function mix(p3, p4, p5)
return p4 + (p3 - p4) * p5;
end;
while true do
local step = game:GetService("RunService").RenderStepped:wait();
fps = (camera.CoordinateFrame.p - character.Head.Position).Magnitude;
if fps < 0.52 then
Z = 0;
else
Z = 0;
end;
if running == true and strafing == false and IsMoving == true then
tick = tick + character.Humanoid.WalkSpeed / 102 * (30*step);
else
if tick > 0 and tick < PI / 2 then
tick = mix(tick, PI / 2, 0.9);
end;
if PI / 2 < tick and tick < PI then
tick = mix(tick, PI / 2, 0.9);
end;
if PI < tick and tick < PI * 1.5 then
tick = mix(tick, PI * 1.5, 0.9);
end;
if PI * 1.5 < tick and tick < PI * 2 then
tick = mix(tick, PI * 1.5, 0.9);
end;
end;
if PI * 2 <= tick then
tick = 0;
end;
camera.CoordinateFrame = camera.CoordinateFrame * CFrame.new(math.cos(tick) / damping, math.sin(tick * 2) / (damping * 2), Z) * CFrame.Angles(0, 0, math.sin(tick - PI * 1.5) / (damping * 20));
end;
I have added a detector to see if the player is moving or not. This should help for things like climbing but standing still same with swimming.