as in the image in the link, I want to get the individual rotations that i have to do on each axis to get to the first part’s orientation
I tried to get the angles individually by separating each of the 3 axis’ vectors as following:
local p1 = Part1.CFrame.LookVector
local p2 = Part1.CFrame:ToObjectSpace(Part2.CFrame).LookVector
local ZPart1 = Vector3.new(P1.X,P1.Y,0)
local ZPart2 = Vector3.new(p2.X,p2.Y,0)
local Zangle = math.acos((ZPart1:Dot(ZPart2))/ (ZPart1.Magnitude * ZPart2.Magnitude))
let’s say we have a part with it’s look vector like this: V3(0,0,-1)
Now, I rotate (yaw) it 90 deg to the right, so now it’s LookVector is like this V3(-1,0,0)
And now, I pitch it to 90 deg counterclockwise. Now the LookVector is V3(0,1,0)
If i run the function with arguments p1 and p2, where p1 is the part after the rotations {V3(0,1,0)} and p2 is the part before the rotations {V3(0,0,-1) } the output would be something like this: V3(90,-90,0)
As I was writing this reply I have realised that i can’t do it with only LookVector. I need all the three vectors, LookVector, UpVector and RightVector to get all the angles
If you want to get the difference of the lookvector and can be used for UpVector ect…
local object1 = ??
local object2 = ??
local dotproduct = object1.CFrame.LookVector:Dot(object2.CFrame.LookVector)
local angle = math.deg(math.acos(dotproduct)) -- math.acos(dotproduct) if just in radians