Get Direction a player is facing on mobile in first person (Including Y-axis)

Hey! I’m looking to get the direction a player is facing in first person on mobile. I can’t use Head.LookVector since I need the Y-axis to be included.

Here’s how it functions on PC:


Excuse the lag, but as you can see, it takes into account the Y-axis.

Here’s how the targeting script currently works on PC:

local mouse = UIS:GetMouseLocation()
local ray = game.Workspace.CurrentCamera:ViewportPointToRay(mouse.X, mouse.Y)
return ray.Origin + ray.Direction * 10000

The problem is that when this is done on mobile, the player’s mouse location is on the movement buttons and not in the center of the screen, unlike how it is on PC.

All help would be greatly appreciated!

local mouse = UIS:GetMouseLocation()
local cam = game.Workspace.CurrentCamera
local ray = cam:ViewportPointToRay(cam.ViewportSize.X/2, cam.ViewportSize.Y/2)
return ray.Origin + ray.Direction * 10000
1 Like

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