Hello everyone,
For some background, my game is in first person and is using R6. What I am trying to offset the camera so it will seem like that the camera is located on the player’s head. I also have another script that rotates joints so the body parts face the camera. The problem is that offsetting the camera makes the character movement very jittery. Without the offset, character movement is silk smooth but as soon as I offset it to the head it just stutters. If I offset the camera off of the humanoid root part upwards only, the character does not stutter.
Stuttering Head Offsetting
local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:wait()
local humanoid = Character:WaitForChild("Humanoid")
local rootpart = Character:WaitForChild("HumanoidRootPart")
local head = Character:WaitForChild("Head")
local torso = Character:WaitForChild("Torso")
local root = Character:WaitForChild("HumanoidRootPart")
game:GetService("RunService"):BindToRenderStep("CameraOffset",Enum.RenderPriority.Camera.Value+1,function(dt)
local offset = rootpart.CFrame * CFrame.new(0,1.5,0)
local headCFrame = head.CFrame
humanoid.CameraOffset = offset:toObjectSpace(headCFrame).Position
end)
Non-Stuttering Humanoid Root Part Offsetting
local plr = game.Players.LocalPlayer
local Character = plr.Character or plr.CharacterAdded:wait()
local humanoid = Character:WaitForChild("Humanoid")
local rootpart = Character:WaitForChild("HumanoidRootPart")
local head = Character:WaitForChild("Head")
local torso = Character:WaitForChild("Torso")
local root = Character:WaitForChild("HumanoidRootPart")
game:GetService("RunService"):BindToRenderStep("CameraOffset",Enum.RenderPriority.Camera.Value+1,function(dt)
humanoid.CameraOffset = Vector3.new(0, 4, 0)
end)
I tried changing the Render Priority but it does not stop the stuttering.
Joint Rotation Script
local function tiltFunc(theta, delta)
neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(-theta, 0, 0);
root.C0 = rootC0 * CFrame.new(0, 0, -1) * CFrame.fromEulerAnglesYXZ(-theta, 0, 0) * CFrame.new(0, 0, 1);
rShoulder.C0 = rShoulderC0 * CFrame.fromEulerAnglesYXZ(0, 0, theta);
lShoulder.C0 = lShoulderC0 * CFrame.fromEulerAnglesYXZ(0, 0, -theta);
rHip.C0 = rHipC0 * CFrame.fromEulerAnglesYXZ(0, 0, -theta);
lHip.C0 = lHipC0 * CFrame.fromEulerAnglesYXZ(0, 0, theta);
end
local renderStepped = game:GetService("RunService").RenderStepped:Connect(function(dt)
tilt.target = math.asin(camera.CFrame.LookVector.y)
tilt:update(dt);
tiltFunc(states[humanoid:GetState()] and 0 or tilt.p / 2, dt);
end)
For the joint rotation script, I tried to change the render priority but it does not stop the stuttering. I’ve also tried to offset the camera after finishing the joint update, but that too does not stop the stuttering. I’ve also tried offsetting from other parts like the Torso which makes it less jittery, but it still jitters.
No Offset:
External MediaYes Offset (Stuttering):
https://streamable.com/0a6law