0 votes

Im doing a game for a project for my school:

I wanted a progress that will fill up by repeatedly pressing the interaction key

asked Dec 2, 2019 in Projects by Regret (29 points)

1 Answer

0 votes
Best answer

ProgressBar works by displaying a value, set by the value property. All you need to do is increase that property's value each time the key is pressed.

Have you already created the scene? Do you already know how to detect input? Your question is not very specific so it's hard to know how much information you need.

If it's just a case of how to increase the bar's display,

func _ready():
    $ProgressBar.value = 0

func _input(event):
    # Assuming you want "spacebar" to be the "interaction key"
    if event.is_action_pressed("ui_select"):
        $ProgressBar.value += 1  # or whatever amount you want
answered Dec 2, 2019 by kidscancode (17,670 points)
selected Dec 3, 2019 by Regret

THANK YOU VERY MUCHH but it would instantly fill up when I hold the Z key (interaction button) any suggestion how to fix that?

When holding a key, your OS typically sends a key echo. You can check for echo and ignore it. See InputEventKey.

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.