MarcoFazioRandom / Virtual-Joystick-Godot

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

Deadzone not respected when using input actions #76

Closed olanti-p closed 3 months ago

olanti-p commented 4 months ago

Hello.

I've tried using the joystick in one of my projects, and run into an issue where the deadzone is not respected when using input actions.

For instance, simply touching the joystick and not moving your finger is enough to trigger "left" action. If finger moves past the right deadzone boundary, the joystick immediately switches to the "right" action, so effectively there is no deadzone at all.

I think I've tracked it down to this code snippet:

https://github.com/MarcoFazioRandom/Virtual-Joystick-Godot/blob/49963c98299995745170353b9424bf0771653115/addons/virtual_joystick/virtual_joystick.gd#L136-L156

Apparently while finger stays in the deadzone, output.x equals 0, so when output.x > 0 condition is evaluated, the false branch is taken, and the "left" action is emitted. Expected behavior in this case would be to not emit either "left" or "right" actions at all. Similar issue with Y axis.

Cheers.