extends Node3D @export var powerbar: ColorRect var powerbar_def_size: Vector2 var powerbar_def_pos: Vector2 var power_value: float = 0.0 var power_value_d: float = 0.0 var powerbar_mode: int = 0 var powerbar_timer: float = 0 # Called when the node enters the scene tree for the first time. func _ready(): powerbar_def_size = powerbar.size powerbar_def_pos = powerbar.position power_value = 0.0 powerbar_mode = 0 powerbar.hide() # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): match powerbar_mode: 0: if Input.is_action_just_pressed("ui_accept"): # Push Space key power_value = 0.0 power_value_d = 1 powerbar_mode = 1 powerbar.color = Color(1, 0.5, 0, 1) powerbar.show() 1: power_value += (delta * power_value_d) if power_value >= 1.0: power_value = 1.0 power_value_d = -1.0 elif power_value <= 0.0: power_value = 0.0 power_value_d = 1.0 if Input.is_action_just_pressed("ui_accept"): # Push Space key powerbar_mode = 2 powerbar_timer = 2.0 # set wait seconds powerbar.color = Color(1, 0.25, 0, 1) 2: # wait powerbar_timer -= delta if powerbar_timer <= 0.0: powerbar.hide() powerbar_mode = 0 powerbar.size.x = power_value * powerbar_def_size.x