0 votes

How should i go about detecting, that a button connected to a script via "pressed()" signal is pressed twice in order to have two functions? First, which is executed when the button is pressed once and the provided condition is true else if the condition is false and the button is pressed twice execute the second function.

in Engine by (44 points)

1 Answer

0 votes
Best answer

maybe u can use a counter

var count = 0

func _ready():
]count = 0

func _pressed(): ]count += 1 ]if count == 1: ]]#first function ]if count == 2: ]]#second function ]]count = 0 (optional to restart it)

" ] " is an indent " ]] " is a twice indent

by (54 points)
selected by
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.
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 webmaster@godotengine.org with your username.