Help me preventing character from shaking

I do not know what you mean but for understanding I will show 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)
end

rs:BindToRenderStep("UpdateSubject", Enum.RenderPriority.Last.Value + 1,updatesubject)

So what might be happening is the script that is updating the camera is doing so before the subject is moved. The script that does that is a Roblox script and can be edited. I’ll look and try to find where.

This might not fix it but try
Enum.RenderPriority.Camera.Value - 1
This will at least be before the script updates the camera.

I tried and It is not working. I think character shaking because the part is too close to head and character moves slow, so part is faster than character and It keeps catch up character

“still shaking”, perhaps decide to show code, i tested with different weight and lerp values and it must be the issue

Okay, here’s the 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)
end

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

and you havent done a thing I have told you to, still relying on heads position

I tried to rely it on HumanoidRootPart position

and i asked a code on you relying on root

Oh, I am sorry. I didn’t do that

I actually didn’t understand what you mean “You relying on root”
EDIT: I was eating sorry for not responding

1 Like

Your head is dynamic, meaning when you are walking, the characters torso which is also dynamic moves along physics, so does the head since it’s attached to your torso. And when you are lerping while walking, you are grabbing Head.Position which can have different Y position at that moment while you grabbed it, making your lerp inconsistent.

Your HumanoidRootPart is the only BasePart by default within your character that is static and does not rely on movement physics, using it would make your lerp point consistent.

local function updateSubject()
    local rootPosition = root.CFrame.Position
    local offset = --// pick your offset from rootPart and make a final position
end
2 Likes

Btw you can see it for yourself, jump into the game, select your character in the explorer, watch the bounding box move on Y axis, then check same with Head and RootPart, you will see what I mean

local offset = rootpart.Position + Vector3.new(0,2,0) is this what you mean by local offset?

Not exactly, it should be just a vector3 representing how many studs is your subject away from rootpart, then create a final variable for your final position and sum your offsets and factors that you may have and just lerp

Can you show me an example please?

local function updateSubject()
    local rootPosition = root.CFrame.Position
    local offset = Vector3.new(2, 0, 0) --// 2 studs further from rootPosition on X axis
    local finalPosition = subject.CFrame.Position:Lerp(rootPosition + offset, 0.5)
    subject.Position = finalPosition
end

somewhat like that, i hate writing code on this platform

Still not working

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 rootpart : Part = script.Parent:WaitForChild("HumanoidRootPart", 3)
local WEIGHT = 15
local camera = workspace.CurrentCamera
local offset = Vector3.new(0,2,0)

function updatesubject()
	local finalPosition = subject.CFrame.Position:Lerp(rootpart.Position + camera.CFrame.XVector * 2.5 + offset, .3)
	subject.Position = finalPosition
end

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

why not just manipulate camera cframe directly?