Going to be honest, I barely have a clue how the camera works, I've just been frankensteining existing camera scripts to no avail. The camera works in a literal sense, but it has horrible stuttering.

Video of stuttering

This is my current code (Localscript named "CameraScript" in StarterCharacterScripts):

--Local script in StarterPlayerCharacter
--Services:
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
--Variables:
local plr = game:GetService("Players").LocalPlayer
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local root = char:WaitForChild("HumanoidRootPart") -- The HumanoidRootPart


--Toggle Function:
function shiftLock(active) --Toggle shift.lock function
	if active then		
		hum.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
		hum.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.
		local Direction = root.CFrame.LookVector.Unit * Vector3.new(0.1, 0,0.1)

		RunService:BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
			local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
			root.CFrame = CFrame.lookAt(root.Position, root.Position + Direction)* CFrame.Angles(0,y,0)
			UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
		end) 
	else

		hum.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
		RunService:UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
		UserInputService.MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
		hum.AutoRotate = true --Let the humanoid handle the camera rotations again.
	end
end

--Disable and Enable:
shiftLock(true) -- Toggle shift lock
--shiftLock(false) --Toggle off shift Lock

3 comments

0

It could be that the character has a default breathing idle animation.

0

And the camera focuses at the root part, even when it's moving either by force or an animation

0

The HumanoidRootPart doesn't move during animations, only the Torso does