extends Node const MAX_PLAYERS : int = 2 const PORT : int = 9374 var ids = [] func _ready() -> void: var peer : NetworkedMultiplayerENet = NetworkedMultiplayerENet.new() peer.create_server( PORT, MAX_PLAYERS ) get_tree().set_network_peer( peer ) get_tree().connect("network_peer_connected", self, "_peer_connected") get_tree().connect("network_peer_disconnected", self, "_peer_disconnected") func _peer_connected(id : int) -> void: if not id: return ids.append(id) print("Player has connected with id " + String(id)) # TODO: When we reach max players -> start the game func _peer_disconnected(id : int) -> void: ids.erase(id) print("Player has disconnected with id " + String(id)) # Called every frame. 'delta' is the elapsed time since the previous frame. #func _process(delta): # pass