I have a custom shiftlock script that changes the cameres position, when the offset value is changed to 1.75 the camera begins to shake violently the lower the clients fps, is there any way to fix this
game:GetService("RunService"):BindToRenderStep("CameraOffset", Enum.RenderPriority.Camera.Value - 1, function(delta)
if plr.Character then
currentCamera = workspace.CurrentCamera
currentCamera.CameraSubject = plr.Character.Head
local offset = Vector3.new(1.75, 0, 0)
TS:Create(currentCamera, TweenInfo.new(.1), {CFrame = currentCamera.CFrame * CFrame.new(offset)}):Play()
end
end)
Tweens have a set time/duration to play which you can specify which in this case is 0.1, but the RenderStepped runs every tick. Meaning before the tween can finish, it’s going to start playing again, causing jittering.
Just use the code I provided in your other post. Be sure to change the offset to your liking:
local plr = game.Players.LocalPlayer
local currentCamera = workspace.CurrentCamera
game:GetService("RunService"):BindToRenderStep("CameraOffset", Enum.RenderPriority.Camera.Value - 1, function()
if plr.Character then
plr.Character.Humanoid.AutoRotate = false
local offset = Vector3.new(1, 0, 0)
plr.Character.Humanoid.CameraOffset = offset
local currentCFrame = plr.Character.PrimaryPart.CFrame
local targetCFrame = CFrame.new(plr.Character.PrimaryPart.CFrame.p, plr.Character.PrimaryPart.CFrame.p + Vector3.new(currentCamera.CFrame.LookVector.X, 0, currentCamera.CFrame.LookVector.Z))
local newRotation = currentCFrame:Lerp(targetCFrame, 10 * game:GetService("RunService").RenderStepped:Wait())
plr.Character.PrimaryPart.CFrame = CFrame.new(plr.Character.PrimaryPart.Position, newRotation.p + newRotation.LookVector)
end
end)
There is a property in Humanoids called CameraOffset, which is a Vector3 value. You can use this property to achieve the same sort of effects that you’re wanting to do. Documentation