I come to you today seeking assistance on this issue. In a game I’m working on, you can use multiple abilities as you run around. Some of which in the future will be timed, so on desktop you might start using your ability (let’s say it’s a flamethrower) and you drag your mouse around to control the flame’s path while you use WASD to move your character.
On mobile however I’m encountering an issue. Apparently using the movement pad on mobile doesn’t count as a GameProcessedEvent (?!?!), so whenever a player is both moving and using the flamethrower ability, the script would have no way of knowing which thumb is meant to be controlling the flamethrower.
I’ve looked up some topics on this but all I could find was a solution to an issue I’m not having. (that issue being how do you tell if a player on mobile is using the movement pad when only one finger is on screen? Use TouchMoved and check the humanoid’s movement speed. But I believe this only works if only one finger is dragging around on the screen.)
Anyway, I appreciate any and all input! Thank you for reading.
So…the script can’t tell whether a given press is for movement, or for aiming, right?
There IS a way to tell fingers apart, I saw a post about it and it used tables or something, but then again, in order for this method to work the script needs to know which finger is used for movement and which is used for aiming. Basically, every TouchStarted event has a “touch” parameter that defines the player’s finger, and that touch stays unique for the lifetime of that specific touch. I’m pretty sure this is in line with what you’re looking for?
You mentioned a method that uses movement speed, I think this could work if you combined it with the method above. My first thought was to put a ScreenGui over the movement pad but, obviously that wouldn’t work on all devices because of aspect ratio and it would likely cause bugs with the desktop version. So instead, you could use the table system in combination with movement speed.
I suppose it’d work like:
Finger is pressed, script notes this in table.
Once a finger starts to move, if the player’s movement speed rises with it, then the script will know that the finger must be the one controlling movement (I’d also check to see if the finger is in the correct corner in case two fingers are moving at once).
The script notes down which finger is to be used for movement and changes some debounce variable to false so that it can’t assign a new finger to movement until the existing one is released.
If the player moves the movement finger, the aim script will know to ignore it.
Once the movement finger is released, debounce is reset, script waits for another finger to move so it can check to see if movement var changes, repeat etc etc
Another method of defeating the “two fingers dragging” would be to check if a finger drags outside of the corner. Obviously if the movement finger strays too far from the movement pad it won’t be used for movement anymore, so the script can recognize this.
I’m not an expert in mobile development or anything and I can already think of a few possible bugs, but given your specific circumstances I think it would at least work.