How to Detect if Player is Looking Front/Back?

I’m trying to make a dashing system where the player dashes back if they are looking behind their avatar and dash forward if they are looking in-front their avatar as a default dash when they aren’t moving. How would I detect which side the player is looking?

Get the dot product of the HumanoidRootPart.CFrame.LookVector and the workspace.CurrentCamera.CFrame.LookVector

local dot = humanoidRootPart.CFrame.LookVector:Dot(workspace.CurrentCamera.CFrame.LookVector)

if dot > 0 then they’re looking forward, if dot < 0 then they’re looking backwards. If dot == 0 then they’re looking exactly perpendicular to their root part, so which direction they dash in is trivial

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.