How do you detect camera movement relatively?

I have been experimenting with different First-Person mechanics in my free time, and are trying to detect what direction the player has turned their screen. The endgoal is to be able to say ‘The player just turned their screen up and to the right’. The only thing I could think of to do, was to have a localscript print workspace.CurrentCamera‘s CFrame.LookVector whenever the camera’s CFrame property changed. This works fine for looking up and down, since you can’t look beyond straight up or down, but looking left to right has some issues. As I expected, as you continue turning left or right, you will eventually reach 1, -1, or 0, and will then start counting up or down in the opposite direction. Hypothetically, if I were to go ‘if the LookVector changes, and it’s X axis is larger than it’s previous X axis, then the player just looked to the left’, and this would work 1/2 the time for a player turning 360° in place’.

How do you detect what direction a player, in first person, looks?

1 Like

Since you are in first person, theres a user input for camera movement.

to tell me the delta x/y i would just do this

local context = game:GetService("ContextActionService")

context:BindAction("CameraMovement", function(_,_,input)
    print("x is: "..tostring(input.Delta.X), "y is: "..tostring(input.Delta.Y))
end, false, Enum.UserInputType.MouseMovement)

(Untested but should work)