Help me preventing character from shaking

  1. What do you want to achieve?
    Prevent character from shaking

  2. What is the issue?
    Character is shaking when i walk

  3. What solutions have you tried so far?
    I was searching solution on forum

Video of my issue:

My code:

local rs = game:GetService("RunService")
local head : Part = script.Parent:WaitForChild("Head", 3)
local rootpart : Part = script.Parent:WaitForChild("HumanoidRootPart", 3)
local subject = script.Object
subject.Position = head.Position
workspace.CurrentCamera.CameraSubject = subject

local WEIGHT = 15
local camera = workspace.CurrentCamera
script.Parent.Humanoid.CameraOffset = Vector3.new(0,.5,0)

function updatesubject()
	subject.Position = subject.Position:Lerp(head.Position + camera.CFrame.XVector * 2.5 + script.Parent.Humanoid.CameraOffset,1/WEIGHT)
	
	local LookXZ = Vector3.new(rootpart.CFrame.LookVector.X, 0, rootpart.CFrame.LookVector.Z)
	--rootpart.CFrame = CFrame.lookAt(rootpart.Position,rootpart.Position + LookXZ)
	--subject.CFrame = CFrame.lookAt(subject.Position, subject.Position + LookXZ)
end

rs:BindToRenderStep("UpdateSubject", Enum.RenderPriority.Camera.Value,updatesubject)

Enum.RenderPriority.Camera.Value + 1 try this

1 Like

Maybe try changing the WEIGHT value from 1/WEIGHT to something like or 2 0.1 or simply just some other value, depending on how smooth you want the movement to be. You may need to experiment with different values to find the best one

subject.Position = subject.Position:Lerp(head.Position + camera.CFrame.XVector * 2.5 + script.Parent.Humanoid.CameraOffset, 0.1)

I tried to change this value and it was still shaking

Uhh that’s really weird then, maybe instead of using Position:Lerp() you could use CFrame:Lerp() as I believe this should smoothly interpolate both position and rotation making the movement somewhat better I guess

function updatesubject()
local targetCFrame = CFrame.new(head.Position + camera.CFrame.XVector * 2.5 + script.Parent.Humanoid.CameraOffset)
subject.CFrame = subject.CFrame:Lerp(targetCFrame, 1/WEIGHT)
local LookXZ = Vector3.new(rootpart.CFrame.LookVector.X, 0, rootpart.CFrame.LookVector.Z)
subject.CFrame = CFrame.lookAt(subject.Position, subject.Position + LookXZ)
end
rs:BindToRenderStep(“UpdateSubject”, Enum.RenderPriority.Camera.Value - 1, updatesubject)

I am sorry but character is still shaking

I’m sorry then but I really don’t know any other things you could potentially change in order to make it functional

me too but It is okay because everyone can make mistakes

1 Like

disable this script to make sure this is the script causing the twiching

No, if I disable this script everything is alright

is this the whole whole code? also try disabling cancollide on your subject part

I disabled CanCollide, CanQuery, CanTouch parameters and nothing works and this is a my whole code

it’s cause of your weight and that ur using Head.Position which is dynamic when character is moving / walking, so the lerp point is not consistent when walking due to head bobbing / moving

consider using character rootPart position and an offset

Still shaking. I tried using tweenservice and It didn’t work too. So I do not know how to prevent character from shaking

Try Enum.RenderPriority.Last.Value
Generally shaking is because you are a frame behind due to incorrect render order.

I tried and It works same as it Enum.RenderPriority.Camera.Value

what is subject? aaaaaaaaaaaaaa

Subject is a part inside the character

Are you updating the camera after updating subject?