mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Use network_peer as a property instead of using the setter method
This commit is contained in:
@@ -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.)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user