extends Node2D const IP = "localhost" const PORT = 9988 var enet # Called when the node enters the scene tree for the first time. func _ready(): var args = OS.get_cmdline_args() var is_host = true if "host" in args: is_host = true elif "client" in args: is_host = false if is_host: print("Starting as host...") enet = NetworkedMultiplayerENet.new() enet.connect("peer_connected", self, "_on_peer_connected") enet.create_server(PORT) get_tree().network_peer = enet else: print("Starting as client...") enet = NetworkedMultiplayerENet.new() enet.connect("connection_succeeded", self, "_on_connection_success") enet.create_client(IP, PORT) get_tree().network_peer = enet func _on_peer_connected(id): print("Connected ", id) func _on_connection_success(): print("Connected")