Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The head does not face the same direction as the camera if the character's orientation isn't 0?

Multiplying, dividing, subtracting, and adding the camera's lookvector x-axis by the HumanoidRootPart's lookvector x-axis didn't help at all.

plr = game.Players.LocalPlayer
char = game.Workspace:WaitForChild(plr.Name)

workspace.CurrentCamera.Changed:connect(function(propString)
    if propString == 'CFrame' then
        char.Torso.Neck.C1 = CFrame.Angles(workspace.CurrentCamera.CFrame.lookVector.Y*-1,workspace.CurrentCamera.CFrame.lookVector.X,0)
		char.Torso.Neck.C0 = CFrame.new(0,1.5,0)
    end
end)

1 answer

✓ Accepted answer

C0/C1 are relative offsets based on the existing orientation of the parts. You're using the camera's world-space CFrame, so the translation made will only look right when the parts in the character have no rotation. Translating the camera into a reference frame relative to the character's rotation first fixes this:

local look = (char.Torso.CFrame:inverse()*workspace.CurrentCamera.CFrame).lookVector
char.Torso.Neck.C1 = CFrame.Angles(-look.Y, look.X, 0)
char.Torso.Neck.C0 = CFrame.new(0, 1.5, 0)

or if you don't want C1,

local look = (char.Torso.CFrame:inverse()*workspace.CurrentCamera.CFrame).lookVector
char.Torso.Neck.C0 = CFrame.Angles(look.Y, -look.X, 0) + Vector3.new(0, 1.5, 0)
char.Torso.Neck.C1 = CFrame.new()

This discussion is preserved as it was. New answers, comments, and votes are closed.