0 votes

Like, every second it adds 0.5 to var numb, when the button is no longer pressed, loop breaks and var numb becomes 0?

Godot version v3.3.4
in Engine by (46 points)

1 Answer

0 votes

Add a button and a timer to your scene, connect the buttondown and buttonup signals of the button and the timeout signal of the timer, then use the following code:

var numb = 0.0

onready var timer = get_node("Timer")

func _on_Timer_timeout():
    numb += 0.5

func _on_Button_button_down():
    timer.start()

func _on_Button_button_up():
    numb = 0.0
    timer.stop()
by (22 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.
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.