class_name ConnectionOverlay extends Control @export var status_label: Label @export_range(1.0, 3.0, 0.1) var fade_out_duration: float = 2.0 var _period_count: int = 1 # Exclusive var _period_max: int = 4 var _is_connected: bool = false func _physics_process(delta: float) -> void: if not _is_connected and Engine.get_physics_frames() % 42 == 0: status_label.text = "Connecting to server" + ".".repeat(_period_count) _period_count += 1 if _period_count == _period_max: _period_count = 0 func _transition_hide() -> void: _is_connected = true status_label.text = "Connected!" create_tween().set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN).tween_property(self, "modulate:a", 0.0, fade_out_duration) await get_tree().create_timer(fade_out_duration).timeout hide() func _on_web_client_connection_status_changed(new_status: WebClient.ConnectionStatus) -> void: # Hides screen once connected. This does not take disconnects into consideration! if new_status == WebClient.ConnectionStatus.LOBBYLESS: _transition_hide()