I know there are other posts like this, But none of them have helped me,
So what im attempting to do, Is so everytime a mobile player clicks while holding a tool, it will fire a remote event, with the position of the middle of their screen, but a bit higher up (to help with aiming)
However, i want to make so the position fired is the point where the gun’s bullet should fire toward, So its like Mouse.hit.p, but at a specific position
this was a bit hard to explain, So tell me if you dont understand, Or need me to explain further.
This is very important because i want mobile players to enjoy my game.
You can use a Raycast that is fired from the Camera, and with the Cameras CFrame rotated on the X Axis, so its higher up. And the Rays Position will be the equivalent to Mouse.Hit.p .This is assuming you are making Guns only for First Person.
I made an Example Script, i have not tested but it should work:
local camera = workspace.CurrentCamera
local CameraUpRotation = 5 --in Degrees
local rayLength = 1000
local rayDirection = (camera.CFrame * CFrame.Angles(math.rad(CameraUpRotation),0,0)).LookVector * rayLength --rotates the cameraCFrame up a little bit and gets the LookVector
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {PlayerCharacter} --ignoring the Characters Parts for the Raycast
local mouseHitRay = workspace:Raycast(camera.CFrame.Position, rayDirection, raycastParams)
local mouseHitPosition = nil
if mouseHitRay then
mouseHitPosition = mouseHitRay.Position
end