#Problem with moving camera along parabolic trajectory

13 messages · Page 1 of 1 (latest)

upbeat forge
#

Hello! S need to move camera by parabolic trajectory while player is moving(for making camera blobbing)but camera is not moving by parabolic trajectory. Here's my code(based on this post: https://devforum.roblox.com/t/movement-along-a-parabolic-trajectory/622730):

local plr = game.Players.LocalPlayer
local humanoid = plr.Character.Humanoid
local camera = workspace.CurrentCamera

-- Camera configuration
camera.CameraType = Enum.CameraType.Scriptable

-- Camera Blobbing
while humanoid.MoveDirection.Magnitude > 0 do
    wait()
    local t = tick() -- Get the current time
    local y = math.abs(math.cos(t) * 5) -- Compute the Y position
    local z = math.abs(math.sin(t) * 5) -- Compute the Z position
    camera.CFrame = CFrame.new(Vector3.new(0, y, z)) -- Update the camera's position
end
keen swift
#

try that

#

nvm dont

#

@upbeat forge what exactly do you mean by parabolic trajectory?

upbeat forge
keen swift
#

since idk what "camera blobbing" is

upbeat forge
keen swift
#
local plr = game.Players.LocalPlayer
local char = plr.Character
local hum: Humanoid = char:WaitForChild("Humanoid")

local running = false

local camerabobcf = CFrame.new()
local cam = workspace.CurrentCamera
local Speed = 5
local ZAxis = .2
local YAxis = .15

game:GetService("RunService").Heartbeat:Connect(function(dt)

    if running then
        camerabobcf = camerabobcf:Lerp(CFrame.new() * CFrame.Angles(
            YAxis * math.sin(tick() * Speed + 1 * dt),
            0, 
            ZAxis * math.sin(tick() * Speed * dt))
            ,.07)
    else
        camerabobcf = camerabobcf:Lerp(CFrame.new(),.07) 
    end

    cam.CFrame = cam.CFrame * camerabobcf 

end)

hum.Running:Connect(function(r)
    Speed = hum.WalkSpeed/1.1
    YAxis = r/450
    ZAxis = r/700
    if r > 1 then
        running = true
    else
        running = false
    end
end)
upbeat forge
#

Thanks! Your code works excellent!

blissful kestrelBOT
#

studio** You are now Level 2! **studio