MarcoFazioRandom / Virtual-Joystick-Godot

A simple virtual joystick for touchscreens, for both 2D and 3D games, with useful options.
MIT License
743 stars 81 forks source link

HTML Mobile Support for Multi-Touch and Visibility #85

Open avivajpeyi opened 3 weeks ago

avivajpeyi commented 3 weeks ago

Thanks for this awesome virtual joystick plugin.

I’m working on a project that uses the joystick in HTML builds (for mobile devices / PCs) and would appreciate any advice on two points:

  1. Multi-touch on HTML builds: Do you have any recommendations or tips to enable multi-touch support so the joystick works seamlessly on mobile browsers?
  2. Visibility on non-mobile HTML: Is there a way to set Visibility Mode <- TouchScreen only so that the joystick is hidden when running on non-mobile HTML environments?

Any guidance on this would be really helpful. Thanks again for your work!

MarcoFazioRandom commented 3 weeks ago

Hello! For the multi-touch issue, have you tried the solution explained in the documentation faq->multitouch-issue? For the visibility, can you explain better what is your goal? When "touchscreen only" is enabled, the script check if the device has a touchscreen, if not the joystick is hidden.

avivajpeyi commented 3 weeks ago

Hey @MarcoFazioRandom , thanks for your reply!

1. Multi-touch: For multitouch -- yes, following your FAQ i had set

"Emulate Touch from Mouse" : ON
"Emulate Mouse from Touch" : OFF
Screenshot 2024-11-05 at 11 07 27 AM

Sorry -- i think my issue was not clear.

2. touchscreen only

I have it enabled to touchscreen only, but it is till rendering the joystick on web_macos/editor?

Screenshot 2024-11-05 at 11 12 57 AM Screenshot 2024-11-05 at 11 16 10 AM
MarcoFazioRandom commented 1 week ago

Hi,

  1. As I understand the joystick is getting touchscreenevents, so maybe the joystick interactable area is covering the other buttons? Can you send a screenshot of the scene with the joystick selected, and one of the joystick's inspector?

  2. In the code I check the visibility mode with if not DisplayServer.is_touchscreen_available() and visibility_mode == Visibility_mode.TOUCHSCREEN_ONLY : I reread the documentation for DisplayServer.is_touchscreen_available(), it's said that it returns true if:

    • OS is Android or iOS
    • the capability is detected on the Web platform -> (Not clear what it means)
    • emulate_touch_from_mouse is true

from the last point, it means that it's always returning true and the code is not working properly, I will change the visibility mode code to check for the OS.

MarcoFazioRandom commented 4 days ago

Hey @avivajpeyi , for the first problem, do you have news? did you solve the problem?