Problem with CFrame angles

So I’ve been digging the internet in search of how to get a CFrame’s rotation in angles
What I want to achieve is to check if a part is behind another

what i thought it would work is to get the angles from the both parts’ CFrame and substract them. If the part1 Y rotation - part2 Y rotation > 0 then part2 is in front of part1 and if it’s lower than 0 it’s behind.

any ideas?
also i thought of using CFrame:ToEulerAnglesXYZ()

1 Like

Are you trying to give the Parts a “Field of View”? Just with the lack of visuals I’m a bit confused in what you mean.

tell me if you need to download any file in order to see the image

Okay, so instead you should be using Dot Products. Dot Products give you a comparison value between -1 and 1 of two Unit Vectors. -1 Means they are facing in complete opposite directions and 1 means they are facing in the exact same direction.

The video below can help explain the whole process, but it comes down to comparing the LookVector of part1 to the Unit Vector between part1 and part2.

Vector3 Dot Product: Calculating NPC Field of View (Roblox Studio) - YouTube

The Video is on NPC FOV but the same principles still apply.

it might work for me too, i’ll let you know if it works

soo, i looked at the video and it solves my problem, thanks. : )