How can i make a camera bobbing script like the one in outlast?

I am trying to make a camera bobbing effect like the one in outlast.
For running and for idle
Example:

If anybody knows please give me an answer! Thank you!

1 Like

for the idle one, you can use a simple sine wave (math.sin) with the delta time of RunService.RenderStepped and just edit some values of the sine wave like the amplitude, phase, etc to get the effect you want

for the movement one, you could probably just edit the values to be bigger so it moves the camera more

repeat that for the axes you want to edit. position x,y,z or rotation x,y,z. then just set the humanoid’s camera offset for position. for rotation just multiply the current camera’s cframe by CFrame.Angles() inputting the radians of rotation

1 Like

How would i do that, if you dont mind? I’ve never really did scripts for bobbing camera.

create a local script and put it in StarterPlayerScripts

the camera can be referenced through workspace.CurrentCamera

connect to RunService.RenderStepped and make sure to have the delta time parameter

position is very easy, you can just get the character, then the humanoid and simply set the CameraOffset to what you want, its a Vector3

rotation is harder (depends, dont remember fully). if the camera is updated every frame then rotation is easy. if not then its a bit harder

(try this method first)
if its updated every frame, instead the RenderStepped connection, just multiply the current camera’s CFrame by CFrame.Angles() with your rotation xyz, like this camera.CFrame *= CFrame.Angles(x, y, z) (if this rotates it by a lot, wrap each parameter in math.rad)

if its not updated every frame, then you need a origin cframe to rotate based off, otherwise you will multiply based off the last rotation, then again and again and the camera will just spin out

local camera = game.Workspace.CurrentCamera
local RunService = game:GetService(“RunService”)

RunService.RenderStepped:Connect(function()
camera.CFrame *= CFrame.Angles(-0.001, 0, 0)
task.wait(1)
camera.CFrame *= CFrame.Angles(0.001, 0, 0)
end)

I’ve made this but its really bugged. What have i done wrong?

In addition the the help you’ve got above, search the forums for ‘camera bobbing’ and you’ll see there are plenty of helpful posts there as well.