Camera offset jittering

I want to make a custom-made camera, but I have an issue. I apply an offset, a Vector3 to the subject position (the HumanoidRootPart). And it doesn’t really follow the camera’s look direction, so I converted it to the camera CFrame’s vector world space using:


Now, It did work quite well, but I have a major issue that this solution causes: jittering and delays (lag behinds). As seen in the gif below:

So far, I did try applying the mouse’s delta (with deltaTime) to the converted offset and the camera’s CFrame, but that didn’t seem to work aswell.

This is my camera’s update code:

local function GetCameraAngles(Camera: Camera, Horizontal: number, Vertical: number): (number, number)
	local Delta = UserInputService:GetMouseDelta() * UserGameSettings.MouseSensitivity * Constants.SensitivityMultiplier

	Horizontal -= Delta.X / Camera.ViewportSize.X
	Vertical -= Delta.Y / Camera.ViewportSize.Y
	Vertical = math.rad(math.clamp(math.deg(Vertical), Constants.VerticalLimit.Min, Constants.VerticalLimit.Max))

	return Horizontal, Vertical

local function CalculateOffset(Camera: Camera): Vector3
	local InitialOffset = Global.CameraOffset
	local Delta = UserInputService:GetMouseDelta()
	Delta *= math.min(ECS.useDeltaTime(), 0.1) * 0.5 -- ECS.useDeltaTime() returns the deltaTime, i made sure of it.
	InitialOffset = (CFrame.Angles(0, -Delta.X, 0) * Camera.CFrame * CFrame.Angles(-Delta.Y, 0, 0)):VectorToWorldSpace(InitialOffset)

	return InitialOffset

local function Calculate(RootPart: BasePart, Camera: Camera, HorizontalAngle: number, VerticalAngle: number): CFrame
	local HorizontalRotation = CFrame.Angles(0, HorizontalAngle, 0)
	local VerticalRotation = CFrame.Angles(VerticalAngle, 0, 0)
	local Offset = CalculateOffset(Camera)
	return * (HorizontalRotation * VerticalRotation)

To reproduce your problem and just to be sure, you are using BindToRenderStepped?

What I can see from the GIF is that it’s sort of moving a little too fast at certain moments, you might expect camera systems to move at the same speed (assuming constant framerate or delta time) or interpolate smoothly (lerp/TweenService) but I don’t see that this is the case here. This could help you diagnose and debug better.

1 Like

I’m running this in a RenderStepped.

Have you tried to use the tweenservice to get a smoother result?

I did try lerping the values, but it doesn’t fix the issue.

I’m struggling to understand why you aren’t just using the simple roblox camera movement…

More custom handling of the camera system.