mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-05 22:09:56 +03:00
fix: there is get_network_peer on SceneTree
This commit is contained in:
@@ -94,12 +94,11 @@ Initializing as a client, connecting to a given IP and port:
|
|||||||
peer.create_client(SERVER_IP, SERVER_PORT)
|
peer.create_client(SERVER_IP, SERVER_PORT)
|
||||||
get_tree().set_network_peer(peer)
|
get_tree().set_network_peer(peer)
|
||||||
|
|
||||||
Note that it may make sense to store the local network peer instance on the SceneTree to be able to access it later,
|
Get the previously set network peer:
|
||||||
as there currently is no `get_tree().get_network_peer()`. This can be done via SceneTree's metadata feature:
|
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
get_tree().set_meta("network_peer", peer)
|
get_tree().get_network_peer()
|
||||||
|
|
||||||
Checking whether the tree is initialized as a server or client:
|
Checking whether the tree is initialized as a server or client:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user