Use network_peer as a property instead of using the setter method

This commit is contained in:
Hugo Locurcio
2020-05-02 01:12:09 +02:00
parent c54d5e320f
commit 726fe7ca1f

View File

@@ -85,7 +85,7 @@ Initializing as a server, listening on the given port, with a given maximum numb
var peer = NetworkedMultiplayerENet.new()
peer.create_server(SERVER_PORT, MAX_PLAYERS)
get_tree().set_network_peer(peer)
get_tree().network_peer = peer
Initializing as a client, connecting to a given IP and port:
@@ -93,7 +93,7 @@ Initializing as a client, connecting to a given IP and port:
var peer = NetworkedMultiplayerENet.new()
peer.create_client(SERVER_IP, SERVER_PORT)
get_tree().set_network_peer(peer)
get_tree().network_peer = peer
Get the previously set network peer:
@@ -111,7 +111,7 @@ Terminating the networking feature:
::
get_tree().set_network_peer(null)
get_tree().network_peer = null
(Although it may make sense to send a message first to let the other peers know you're going away instead of letting the connection close or timeout, depending on your game.)