How do I go about getting the horizontal angle between two look vectors? This is what I have so far:
local cameraPosition: Vector3 = camera.CFrame.Position
local lookVector: Vector3 = humanoidRootPart.CFrame.LookVector -- The angles x, y, and z of the player's character
local cameraVector: Vector3 = camera.CFrame.LookVector -- The angles x, y, and z of the player's camera
local yOffset: TypeUtil.double = math.pi / 2
local zOffset: TypeUtil.double = math.pi / 2
local verticleAngle: TypeUtil.double = yOffset + cameraVector.Y
local horizontalAngle: TypeUtil.double
if (isMovementEnabled) then
TweenService:Create(rightShoulder, moveTweenInfo, {
C0 = rightShoulderCFrame * CFrame.Angles(verticleAngle, 0, 0)
}):Play()
end
basically, you want to multiply the point vectors entries then add them all up (dot product) then since this value you returned could be interpreted as a cosine sine value (as you got the dot product of unit vectors, ie that means their range will be equal to -1 to 1, the same range as of cosine and or sine. so knowing that the resulteed value will be a radian you could just convert that format to the one you want by multiplying it by 180/pi (math.deg)
Yes, but I just need the horizontal angle, so which two vectors would I apply the cross product on? I am doing the LookVector of the player’s HumanoidRootPart and the player’s CurrentCamera.