I want to use a similar result to mouse.hit.p but for mobile
I want to make this on mobile
What is the issue?
There’s no mouse.hit.p equivalent to mobile, not even controller equivalent.
What solutions have I tried so far? I’ve been looking through google for examples where people suggested mouse.hit.p replacements and there seemed to be none. I want mobile, exactly mobile, to have this ability to summon different pieces on each mouse.hit.p that it does, it has been built for that.
How the mechanism works is that it selects a sauce piece and sets it on the mouse.hit.p location, and it doesn’t go to the floor because there’s an invisible roof colliding with mouse.hit.p which causes the piece to not fall to the banana.
I just need to get the touch position of the phone, and transform that position into a coordinate in vector3 position, where Y can be 300 or anything, too.
Some people suggested on a different topic that, to replace mouse.hit, you should use camera:viewportpointtoray, but I don’t think it’s what Im looking for, that plus the fact that I don’t understand it. Maybe it is what I need, I don’t know.
Userinput services touch started is what I believe you are looking for since you are dragging the mouse along the screen to lay the sauce, code sample is all there just copy and paste and rework it into your example instead of dragging a GUI it does the sauce thing so just change the Update function in the code example:
Edit: Oh yeah once you get the touch location through the code sample you can use the following function after a few adjustments to get “mouse.Hit.P” from the screen location
local UserInputService= game:GetService("UserInputService")
local RAY_DISTANCE = 1000 -- default ray distance like mouse.Hit
local cam = workspace.CurrentCamera
function hitPositionFromScreenLocation(raycastParams, distance)
local mousePos = --replace with touch location
local viewportMouseRay = cam:ViewportPointToRay(mousePos.X, mousePos.Y)
local rayCastResult = workspace:Raycast(viewportMouseRay.Origin, viewportMouseRay.Direction * (distance or RAY_DISTANCE), raycastParams)
local hitPosition
if rayCastResult then
hitPosition = rayCastResult.Position
else
hitPosition = viewportMouseRay.Origin+viewportMouseRay.Direction * (distance or RAY_DISTANCE)
end
return hitPosition
end
I’d probably use a ProximityPrompt to attach the rope thing to the player.
Or maybe a custom cursor on the screen, as seen in Windows XP Error Sim.(💾 Windows Error Simulator - Roblox)
It doesnt seem to be what Im looking for, but it looks useful nonetheless. Thank you for this info, I would have done another thread to know this in particular.