How to get camera direction relative to a Character's Root Part

Hi, basically I would like to change an animation depending on which way the camera is facing relative to the player. If the camera is facing to the right of the player, change the animation accordingly, if left, change it again. I would like to be able to identify all six directions that the camera can face, right, left, up, and down, forward, and backwards. I’ve tried looking at the :Dot product of the angles, but it seems to only work for looking forward and backward. When I tried using the RightVector instead of the Lookvector for the :DotProduct it does wonky stuff. Does anybody know a way I can identify all six directions that the camera can be facing relative to the player?

1 Like
local cameraOffset = root.CFrame:Inverse() * camera.CFrame

That will give you a CFrame which, if you did root.CFrame * cameraOffset, would get you the camera CFrame again.

You could use that however you wish. Examine the look vector, call toEulerAnglesXYZ on it, or snap it to a particular axis or something.

4 Likes

Perfect! Your attached thread also helped me figure things out as well!