I'm using a function named start_client
or start_server
to start the server and the client, but i want it able to be runned multiple times if needed.
I first had this:
var network = NetworkedMultiplayerENet.new()
func create_server() -> void:
network.create_server(5555, 10)
get_tree().set_network_peer(network)
But i was getting this error: create_server: The multiplayer instance is already active
I then tried this:
var network = NetworkedMultiplayerENet.new()
func create_server() -> void:
network = NetworkedMultiplayerENet.new()
network.create_server(5555, 10)
get_tree().set_network_peer(network)
No errors this time, but for some reason, the client wasn't able to connect to the server. I tried multiple times but couldn't get it to work a single time.
And lastly i tried this:
var network = NetworkedMultiplayerENet.new()
func create_server() -> void:
network.close_connection()
network.create_server(5555, 10)
get_tree().set_network_peer(network)
And i got this error: close_connection: The multiplayer instance isn't currently active
I couldn't find any way to test if the client/server was already created. I could probably use a boolean to keep track of the network state but I want ot know if there is a cleaner way to achieve this.