What do you want to achieve? Keep it simple and clear!
Understand Trigonometry in script.
What is the issue? Include screenshots / videos if possible!
This script makes the characters head rotate relative to your cameras position. But I do not get how the trigonometry works.
I get that arcsine of opposite/hypotenuse = degrees, but why is the opposite site of the triangle the x and then the y coordinate of the cameras lookvector? From what I understand you make a vector from the humanoidrootpart to the camera and then get the cameras lookvector but I dont understand what happens after this (see picture). Thanks for the Help!
local camera = workspace.CurrentCamera
local character = game.Players.LocalPlayer.Character
local root = character:WaitForChild("HumanoidRootPart")
local neck = character:FindFirstChild("Neck", true)
local yOffset = neck.C0.Y
local CFNew, CFAng, asin = CFrame.new, CFrame.Angles, math.asin
local cameraDirection = root.CFrame:toObjectSpace(camera.CFrame).lookVector
if neck then
neck.C0 = CFNew(0 , yOffset, 0) * CFAng(0, -asin(cameraDirection.x), 0) * CFAng(asin(cameraDirection.y), 0, 0)
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Tried looking at the devforum for trigonometry in 3d space.