Recently, I attempted on making the character face the same direction as the camera. It worked, only problem is that the character tilts when strafing or moving backwards.
Angles and Orientation are a pain to work with. If you’re alright with dumping the orientation math, I have the solution for you.
local RS = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local root = char:WaitForChild("HumanoidRootPart")
local cam = workspace.CurrentCamera
RS.RenderStepped:Connect(function()
local origin = root.CFrame.Position
local look = cam.CFrame.LookVector
local flat = Vector3.new(1,0,1)
root.CFrame = root.CFrame:Lerp(CFrame.new(origin, origin + (look * flat)), .5)
end)
This code simply uses the second argument of CFrame.new() to create a LookAt function.
We basically just take the origin (aka the current root CFrame) and make it look at the origin + the LookVector of the camera.
We also multiplied the LookVector by (1,0,1), we did this because it removes the Y value so that the character only follows the X and Z of the camera.
When tested on a blank baseplate the script works fine, the problem most likely lies within the code affecting the camera. Do you have the code that updates the camera’s position readily available? if so I can take a glance over it and check for any gleaming problems!
The only scripts in the place are modules that have nothing to do with the camera. Aside from that, I’ve only messed with the cameraoffset and the mousebehavior.
No problems. Humanoid.AutoRotate can cause problems with custom character rotation, so it’s always best to turn it off if not needed. Also solves possible character stutters when using over-the-shoulder camera systems.