how do i assign a network peer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mautu

I had recently followed a tutorial on how to make a multiplayer game on YouTube and had attempted to add the system to my own game. as of now I keep getting the following error message every time I try to run my code :

:E 0:00:01.624 get_network_unique_id: No network peer is assigned. Unable to get unique network ID.
<C++ Error> Condition “!network_peer.is_valid()” is true. Returned: 0
<C++ Source> core/io/multiplayer_api.cpp:794 @ get_network_unique_id() @ _physics_process()

I’m relatively new to Godot and am not fully sure what this means. it seems to happen whenever is_network_master() is called. any help would be greatly appreciated.

:bust_in_silhouette: Reply From: SteveSmith

You need to create the network peer:-

get_tree().network_peer =

Then call create_client() or create_server() on it.

link to code
I just cant get it to work wondering if you would be willing to look at to see why it keeps resulting in errors?

mautu | 2023-02-06 23:17

I ad a quick look, and you’re not setting the network_peer. Are you doing that elsewhere?

SteveSmith | 2023-02-07 07:26

I think I tried to and still got many errors mainly with the preloading but some of the same issues

mautu | 2023-02-07 14:14