Problem with lock on. There is dismatch between Camera rotation and HumanoidRootPart Orientation

  1. I want to fix my Character “Lagging” its’ rotation.

If I Lerp Camera CFrame(the main problem):

If I don’t Lerp but just set camera CFrame to CameraTargetCFrame:

You can see my character body glitching, like it’s rotation being overriden multiple times(but nothing should cause it)

The problem isn’t happening if I set camera CFrame instantly(instead of Lerping and using deltatime from Runservice.RenderStepped)

local TargetRotation = CFrame.lookAt(HumRP.Position, Vector3.new(TargetPosition.X, Y_Target, TargetPosition.Z))
	HumRP.CFrame = TargetRotation

local X = HumRP.CFrame.RightVector * OFFSET_X
local Y = Vector3.new(0, OFFSET_Y, 0)
local Z = HumRP.CFrame.LookVector * OFFSET_Z
local CAMERA_OFFSET = X + Y + Z
			
local CameraTargetCFrame = CFrame.lookAt(HumRP.Position + CAMERA_OFFSET, TargetPosition)
	Camera.CFrame = Camera.CFrame:Lerp(CameraTargetCFrame, math.clamp(dt * 22, 0, 1))

I only think here main of problem with code fasting also in math clamp because his value out 1 to one not multiple for dt, try deleted math clamp and just put dt for accelerate of rotation

Deleting math.clamp or changing accelerate value don’t help. Also here’s what print(math.clamp(dt * 22, 0, 1)) looks like in output:

By “code fasting” you mean it takes too long to complete function? If yes then no, because I tested it and nothing changed(I just deleted other code, but nothing changed)

Nevermind, I got the solution.

I just replaced
Camera.CFrame = Camera.CFrame:Lerp(CameraTargetCFrame, math.clamp(dt * 22, 0, 1))

With
Camera.CFrame = Camera.CFrame:Lerp(CameraTargetCFrame, 0.5)

I guess frame update difference caused huge difference between each camera movement, so it looked choppy.

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