I’m pretty sure this has been answered numerous times already, but I want this to specifically work around a certain point.
That finds the angle between two vectors from the world origin. I want to find it from a point.
That still works. You just take the distance between B and A and then C and A then use cosine to find it.
Let the points of the triangle be ABC with B as the origin.
construct the two vectors BA and BC:
use the parts .Position property
local BA = A.Position - B.Position
local BC = C.Position - B.Position
now get the angle of the constructed vectors using the method @maycoleee2231 suggested.
local angle = math.acos(BA:Dot(BC))
I haven’t tested this but it should work. I can draw a diagram of my thinking if needed.
It returns -nan(ind) for some reason
print(math.deg(math.acos((workspace.C.Position-workspace.A.Position):Dot(workspace.B.Position-workspace.A.Position))))
That’s what I did
print(math.deg(math.acos((workspace.C.Position-workspace.A.Position):Dot(workspace.B.Position-workspace.A.Position))))
A = B
C = A
B = C
Left is mine and right is yours
(workspace.C.Position-workspace.A.Position):Dot(workspace.B.Position-workspace.A.Position)
I found the error. I forgot to unitise the vectors. Add .Unit onto the end of the vectors and then get the angle between them. I tested this with a triangle with the ratio 60 30 90 and got the expected results for the angle
local A = workspace.A
local B = workspace.B
local C = workspace.C
local BA = (A.Position - B.Position).Unit
local BC = (C.Position - B.Position).Unit
local angle = math.acos(BA:Dot(BC))
print(angle)