How do i make the FPS camera movement Smooth?

I know that i have to use Lerp and Delta But i don’t know What to Lerp with the camera

For exemple : Doors Camera Movements are smooth

Thanks for your reply
(sorry for bad english)

1 Like

make a part and then set the camera subject to the part

then move the part each frame in a Runservice.Stepped loop with this formula

for my game i have:

moveDivisor set to 3
framerate set to 1/60
dt is the difference in time between the runservice loops
targetPosition is a few studs above the humanoidrootpart

local diff = targetPosition - part.Position

part.Position += diff / moveDivisor / (framerate/dt)
1 Like

I tried but it resulted into making the Camera Y position infinite

-- Services

local RS = game:GetService("RunService")

-- Variables

local Player = game.Players.LocalPlayer
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera


-- Parameters

local MoveDivisor = 3
local Framerate = 1/144

-- Functions

local function CreatePart()
	local Part = Instance.new("Part")
	Part.Anchored = true
	Part.CanCollide = false
	Part.Transparency = 1
	Part.Size = Vector3.new(.5, .5, .5)
	Part.Position = HumanoidRootPart.Position
	Part.CastShadow = false
	Part.CFrame = Camera.CFrame
	Part.Name = "CameraPart"
	Part.Parent = workspace
	return Part
end

-- User Inputs

local CameraPart = CreatePart()
Camera.CameraSubject = CameraPart

RS.Stepped:Connect(function(deltaTime)
	local Diff = Vector3.new(HumanoidRootPart.Position.X, HumanoidRootPart.Position.Y + 1.5, HumanoidRootPart.Position.Z) - CameraPart.Position
	CameraPart.Position += Diff / MoveDivisor / (Framerate/deltaTime)
end)

Making the CameraType to scriptable didn’t work

This is my method of using it from my older replies to a similar problem. An example of using it from my gun script:

local function camRecoil(mousePos,random)
	local direction = Vector3.new(mousePos.X-char.HumanoidRootPart.Position.X,0,mousePos.Z-char.HumanoidRootPart.Position.Z).Unit*VRecoil
	local radDirection = Vector3.new(direction.Z,0,-direction.X)*HRecoil*random

	local VSpring = springModule.new(5, 7.5, 45, math.random(55,80)/100, -2.5, 0)
	local HSpring = springModule.new(5, 7.5, 45, math.rad(150,200)/100, 2.5, 0)
	game:GetService("RunService"):BindToRenderStep("recoil", Enum.RenderPriority.Camera.Value, function()
		local VOffset = -direction*VSpring.Offset
		local HOffset = radDirection*HSpring.Offset
		cam.CFrame = CFrame.new(cam.CFrame.Position+HOffset+VOffset)*(cam.CFrame-cam.CFrame.Position)
	end)
end

variable random is just the direction of the Horizontal recoil to left or right, Vrecoil and HRecoil are constants that determine how strong the recoil is, this is a top-down camera gun system so use this only as an example.

stepped gives 2 arguments (time, deltaTime)

try this

-- Services

local RS = game:GetService("RunService")

-- Variables

local Player = game.Players.LocalPlayer
local Character = Player.Character
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera


-- Parameters

local MoveDivisor = 3
local Framerate = 1/144

-- Functions

local function CreatePart()
	local Part = Instance.new("Part")
	Part.Anchored = true
	Part.CanCollide = false
	Part.Transparency = 1
	Part.Size = Vector3.new(.5, .5, .5)
	Part.Position = HumanoidRootPart.Position
	Part.CastShadow = false
	Part.CFrame = Camera.CFrame
	Part.Name = "CameraPart"
	Part.Parent = workspace
	return Part
end

-- User Inputs

local CameraPart = CreatePart()
Camera.CameraSubject = CameraPart

RS.Stepped:Connect(function(time, deltaTime)
	local Diff = Vector3.new(HumanoidRootPart.Position.X, HumanoidRootPart.Position.Y + 1.5, HumanoidRootPart.Position.Z) - CameraPart.Position
	CameraPart.Position += Diff / MoveDivisor / (Framerate/deltaTime)
end)

I’m sorry for the late respond, i have tried it but it doesn’t seem to work
it just doesn’t do anything except i can’t go in first person