This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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

in Engine by (13 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.

by (3,164 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.