From 2730899f9e99fbd9f0f3e74da9a564ef4a114164 Mon Sep 17 00:00:00 2001 From: copygirl Date: Sun, 8 Dec 2024 13:05:17 +0100 Subject: [PATCH] Add clear_player_models helper function --- copyMultiplayer.gd | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/copyMultiplayer.gd b/copyMultiplayer.gd index 01cba63..b1a1d0b 100644 --- a/copyMultiplayer.gd +++ b/copyMultiplayer.gd @@ -89,6 +89,7 @@ func disconnect_pressed() -> void: set_status("") print_log("Closed server") update_enabled_state(false) +clear_player_models() multiplayer.multiplayer_peer.close() @@ -129,13 +130,7 @@ func server_disconnected() -> void: set_status("") print_log("Disconnected from server") update_enabled_state(false) - - for controller in get_children(): - if controller is ModelController: - remove_child(controller) - controller.queue_free() - - player_order.clear() +clear_player_models() func update_enabled_state(is_online: bool) -> void: @@ -169,6 +164,13 @@ func update_status() -> void: var s := "s" if num_players != 1 else "" set_status([side, ": ", num_players, " player", s]) +func clear_player_models() -> void: + for controller in get_children(): + if controller is ModelController: + remove_child(controller) + controller.queue_free() + player_order.clear() + @rpc("any_peer", "reliable") func change_model(filename: String) -> void: