Add clear_player_models helper function

main
copygirl 3 weeks ago
parent 4c4bd2c903
commit 2730899f9e
  1. 16
      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:

Loading…
Cancel
Save