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()
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.