Hello, I’m struggling a bit with relative rotations right now. I’m wanting to find which side of a part, the humanoidrootpart is relative to in degrees.
Example: Right side being 90 degrees, left side being 270 degrees, front side being 0 (360) degrees & back side being 180 degrees.
Illustration:
I don’t know a good way of explaining this, so it’d be great if someone understands what I mean.
So if I understand this question correctly, you want to find out, given some part, if the player is more ‘in front’, ‘to the left’, ‘to the right’ or ‘behind’ that part given its orientation and position?
I’m pretty sure you can do this by comparing vectors(?)
I was looking at this yesterday so it’s still pretty fresh in my mind.
Assuming the part is at point (a1,a2) along the X and Z axis and the player is at point (b1,b2) you can do
angle = math.atan((b2-b1)/(a2-a1)) --(in radians)
You may have to switch the numerator and denominator if the angle is wrong, but I’m pretty sure this is what you want
If I understand your problem correctly, you could use the dot product.
local unit = (game.Workspace.Metro_AA.HumanoidRootPart.Position -game.Workspace.Part.CFrame.p).unit
print(math.deg(math.acos(game.Workspace.Part.CFrame.LookVector:Dot(unit))))