Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a Camera Bob?

Asked by 10 years ago

Is there like a good way?

3 answers

Log in to vote
2
Answered by 10 years ago

Here, I just made one. It's a little bit wonky, but should do fine for you:

wait(0.1)
local cam = game.Workspace.CurrentCamera
local player = game.Players.LocalPlayer
local char = player.Character
local rs = game:GetService("RunService")
local lastTick = tick()
local t = 0
local headPos = char.Torso.Neck.C0
local running = false

char.Humanoid.Running:connect(function(speed)
        running = speed > 0
end)

while true do
    rs.RenderStepped:wait()
    local dt = tick()-lastTick
    if running then
        t = t+dt

        char.Torso.Neck.C0 = headPos * CFrame.new(math.cos(t*8)*0.1, 0, math.abs(math.sin(t*8))*0.1)
        local look = cam.CoordinateFrame.lookVector
        cam.CoordinateFrame = CFrame.new(cam.CoordinateFrame.p, cam.CoordinateFrame.p+look) * CFrame.Angles(0, 0, math.rad(math.cos(t*8)))
    end
    lastTick = tick()
end

Notes:

  • It must be a local script
  • It goes in StarterGui
Ad
Log in to vote
0
Answered by 10 years ago

Please help! I am wondering this too!

Log in to vote
0
Answered by
IdoWhy 0
3 years ago
Edited 3 years ago

Hey ya, I've made a script, sorry for 6 years late lol

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Humanoid = workspace:WaitForChild(Player.Name).Humanoid
local Head = Humanoid.Parent.Head
local HumanoidRootPart = game.Workspace[Player.Name].HumanoidRootPart
local Mouse = Player:GetMouse()
while true do
    wait()
    Humanoid.CameraOffset = Head.Position - HumanoidRootPart.Position + Vector3.new(0, -1.5, -1)
end


Basically, it changes the humanoid offset to the head position minus humanoid root part position, and then the camera is close to the head, you can change the position how you'd like to with just simply changing the Vector3 value. No problem :)

Answer this question