Hello! I’m trying to make the character’s head and torso follow the camera’s LookVector. I did some researches and I found this youtube video:
I understand everything but the algorithm. Can anyone explain the algorithm to me please?
My Code:
local char = plr.CharacterAdded:Wait()
local head = char:WaitForChild("Head")
local neck = head:WaitForChild("Neck")
local neckC0 = neck.C0.p
local torso = char:WaitForChild("UpperTorso")
local waist = torso:WaitForChild("Waist")
local waistC0 = waist.C0
local cam = workspace.CurrentCamera
game:GetService("RunService").RenderStepped:Connect(function()
if neck then
local camPos = char:WaitForChild("HumanoidRootPart").CFrame:ToObjectSpace(cam.CFrame).LookVector
neck.C0 = CFrame.new(0, neck.C0.Y, 0) * CFrame.Angles(0, -camPos.X, 0) * CFrame.Angles(camPos.Y, 0, 0)
waist.C0 = CFrame.new(0, waist.C0.Y, 0) * CFrame.Angles(0, -camPos.X, 0) * CFrame.Angles(camPos.Y, 0, 0)
end
end)
Any help is apprieciated! Thanks!
What I want to ask is, why do we use neck.C0.Y, -camPos.X and camPos.Y?