Hello,
I’m making a mix of 2d and 3d game, and what I’m doing right now is making the character point towards the mouse position when attacking. Everything works well on PC so I’m trying to add support to mobile but I’m having issues.
I’m currently using UserInputService.InputChanged to detect when the player touches their mobile device (through Enum.UserInputType.Touch), however this event fires when the player touches the screen on the thumbstick so they can move their character, thus making the character attack and point in the wrong direction. My goal was to drag the right finger on the screen to aim the attack and release the finger to fire the attack, while the left finger is used to move the character with the default Roblox thumbstick as usual.
Is there any event that fires only when the player touches and drags their finger across the device on the world space rather than InputChanged that fires with GUIs too? I’ve tried UserInputService.TouchTapInWorld (that in part does exactly what I need) but it’s useless as it fires after the player releases the finger, meaning they cannot aim the attack correctly by keeping their finger on the device.
You can use the GameProcessedEvent argument to your advantage like this:
UserInputService.InputChanged:Connect(function(input, GameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Touch and not GameProcessedEvent then --The touchinput was not processed by the game which means the player was not interacting with their thumbstick
--Do magic
end
end)
Hi, I’ve tried this and unfortunately the problem persists. I think GameProcessedEvent is true only when the player is pressing an actual button or a text box, whilst I’m pretty sure the thumbstick is just an image label. Thanks for trying though.
You can also keep a reference to the player’s humanoid and instead of checking the GameProcessedEevent, you can check the Humanoid’s MoveDirection and if it is not equal to “Vector3.zero” then the player is interacting with their thumbstick otherwise they’re not
True, but then the player would not be able to aim while moving. I uploaded a clip of the issue on my original post if you’d like to see the issue more clearly.