How would i make the camera move in delay roblox

Can someone help me make the roblox first person camera move in delay
Basically when you move the cursor the camera movement lasts longer than when you stop moving the mouse, just like in the roblox horror games

Do you want it to be actually delayed or just have inertia / swinging effect?

use this service roblox provides: TweenService | Roblox Creator Documentation

I would want it to be like an inertia effect

This is scripting support - please either provide your script or show what you’ve attempted before creating a topic.

As for the quesiton, please do some research first.
The Fastest Camera System You’ll Probably See Written For Roblox! - Resources / Community Resources - DevForum | Roblox
How would i make this camera script smoother - Help and Feedback / Scripting Support - DevForum | Roblox
How to tilt camera smoothly based on the players movement - Help and Feedback / Scripting Support - DevForum | Roblox

Try this,

-- local script (characterscripts)
local char = script.Parent
local camera = game.Workspace.Camera
local smoothness = 20 -- the bigger the number, the smoother

while wait(1/smoothness) do
	camera.CFrame = camera.CFrame:lerp(char.Head.CFrame, 1/smoothness)
end

sorry for the bump.

(the lerping will also preserve the orientation)

Maybe something like this would work.

local sensitivity = 0.1 -- How much "inertia" when moving the camera
local deceleration = 10 -- How fast the speed decelerates.

local cam = workspace.Camera

local rotate = Vector3.zero
local max = math.max
local rad = math.pi/180

local mouseMove = Enum.UserInputType.MouseMovement
game:GetService'UserInputService'.InputChanged:Connect(function(input)
	if input.UserInputType == mouseMove then
		rotate -= input.Delta*sensitivity
	end
end)

game:GetService'RunService':BindToRenderStep('InertialCamera',Enum.RenderPriority.Camera.Value-1,function(dt)
	rotate *= 1-dt*deceleration
	cam.CFrame *= CFrame.fromOrientation(rotate.Y*rad,rotate.X*rad,0)
end)
4 Likes

try my code out, and compare the difference. I want to see.

First, your code runs in a wait loop, mine runs on a render stepped meaning yours is not very smooth and mine is. Second, you are setting the camera to the head cframe, mine is using UserInputService to check for camera rotations. Mine will actually do an “inertial” movement, yours will just slowly set it to the heads cframe (which is already where the camera is looking at) so theres almost no lerping happening. Third, since yours will follow the head, any animation involving the head, like the R15 idle, will actually make the camera change its rotation.

Video proof (Sorry my pc isn’t powerful enough to support recording with stable 60 fps)
My code:


The configuration for this is 0.1 sensitivity and 10 deceleration.

Using my code, the camera actually gives a feeling of inertia. Like the camera doesn’t stop immediately.

Your code:


The configuration for this is 30 smoothness, the fastest you can go with wait(). If you used task.wait() you can use up to 60.

As you can see there is no “inertia” feeling when moving the camera. The camera stops immediately. The reason my camera is lerping to the center is because it lerps towards the head cframe. Since the head cframe only moves horizontally, your code doesn’t support vertical rotation unless you make a “head-follow-camera” script.

4 Likes

@mafuuyuuuuu Use this guy’s script

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