I’m currently doing my first attempt at a custom camera controller.
It works as intended except for the fact that I can only turn when holding down the right click button. When walking backwards there also appears to be stuttering / glitching.
robloxapp-20200714-1929478.wmv (1.9 MB)
I’ve been looking for a couple hours through other people’s custom character controllers to figure this out and can’t seem to find one with an issue with turning without holding right click.
Thank you very much for any help, below is all the code at this point which is in a LocalScript inside StarterPlayerScripts.
local UserInputService = game:GetService("UserInputService")
local camera = workspace.CurrentCamera
local player = game:GetService("Players").LocalPlayer
game:GetService("RunService").RenderStepped:connect(function()
if player.Character then
local root = player.Character.HumanoidRootPart
if root then
player.Character.Humanoid.CameraOffset = Vector3.new(2,1,0)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
root.CFrame = CFrame.new(root.CFrame.p,root.CFrame.p + Vector3.new(camera.CFrame.lookVector.X ,0 ,camera.CFrame.lookVector.Z))
end
end
end)