0 votes

Hello, I'm not sure if this is the correct category, but I'm currently working on a dialogue display UI that also includes dialogue choices and came across an issue.

Basically, I currently have a list of buttons stored in an array list variable and I'm using event.isactionpressed() to control which button is in focus.

if event.is_action_pressed('up') :
  if focus_button_index == 0:
    focus_button_index = choice_buttons.size() - 1
    focus_button_index -= 1

The problem I'm currently having is that the up action is on the joystick, and as I lean the joystick forward, it be considered "pressed" and "released" multiple times in one forward lean. Is there something wrong with my joystick or am I just using this function incorrectly?

In case the description was unclear, I'll try to use angles to describe what the code would do:

With the joystick in the center (0 degrees): nothing happens.
I push it forward 10 degrees: nothing happens (still in joystick dead zone I assume)
I push it forward another 10 degrees (now at 20 degrees) without going back to the center: code enters if-statement
I push it forward another 10 degrees (now at 30 degrees) without going back to the center: code enters if-statement AGAIN

asked Oct 6, 2017 in Projects by NikOrin (12 points)

You can read the joystick in an analog way(which is the right way imo since joystick is an analog sensor) or you can use a timer/release mechanic to prevent this thing

1 Answer

0 votes

Leave it to good ol' Ivan Skodje to answer this question. When you press "up", you have the code wait a few seconds, and check again. It's something like "if the user is pushing up, assign a variable to keep track of whether they're pressing up, then wait a few seconds, and check again".

Hope that helps.

answered Oct 8, 2017 by Ertain (1,389 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.