MarcoFazioRandom / Virtual-Joystick-Godot

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

Input processing Issue #55

Closed keithrdavis closed 1 year ago

keithrdavis commented 1 year ago

The joystick is working with "Use Input Actions".

Emulate touch from mouse is disabled. Emulate mouse from touch is enabled for menu and player action buttons e.g. the attack button.

I have a TextureButton with the following code:

func _on_AttackButton_down():
    Input.action_press("ui_attack")

func _on_AttackButton_up():
    Input.action_release("ui_attack")

When using just keyboard input without the Joystick and TextureButton, I can move and attack simultaneously. When using the Joystick/TextureButton on a mobile device to move and attack, I can only do one or the other. Sometimes if I press & hold the TextureButton first to attack and then touch/move the joystick I can do both (Doing movement with joystick first then pressing attack does not work). I wonder if this is because of the button and the need for mouse emulation so the button works when touched.

Any ideas? Thanks in advance!

MarcoFazioRandom commented 1 year ago

Hello, as stated in the README, you should have this configuration:

"emulate touch from mouse" ON "emulate mouse from touch" OFF

because only the inputs from the touch support multitouch.

keithrdavis commented 1 year ago

I did go over the README setting suggestions; however, if I use those settings, my buttons don't work i.e. my main menu has buttons and they won't function without having "emulate mouse from touch" ON.

MarcoFazioRandom commented 1 year ago

I understand, but the problem is that in Godot if you use the mouse you can't use multitouch, it has nothing to do with this my script, and I can't do anything about it.

I don't know why your buttons don't work with that options ON, that seems the problem that needs to be fixed.

I won't close this issue right now because someone else could run in the same problem in the future, please when you fix it comment here or link to the solution you found.

keithrdavis commented 1 year ago

I fixed it. I was using TextureButton for my mobile play buttons. Changing them to TouchScreenButton fixed the issue.