Kehom / GodotAddonPack

A collection of pure GDScript addons for Godot
http://kehomsforge.com
MIT License
183 stars 15 forks source link

[Network] get_node: Node not found: @@8 when connecting to server #30

Closed croxis closed 3 years ago

croxis commented 3 years ago

Or: croxis needs to commit more often so breaks are easier to revert!

I did... something which is causing errors to be thrown and I am not sure where to start looking to fix it. I used the dedicated server tutorial as the template.

E 0:00:32.735 get_node: Node not found: @@8. <C++ Error> Condition "!node" is true. Returned: __null <C++ Source> scene/main/node.cpp:1381 @ get_node()

E 0:00:32.735 _process_get_node: Failed to get path from RPC: @@8. <C++ Source> core/io/multiplayer_api.cpp:256 @ _process_get_node()

E 0:00:32.735 _process_packet: Invalid packet received. Requested node was not found. <C++ Error> Condition "node == __null" is true. <C++ Source> core/io/multiplayer_api.cpp:204 @ _process_packet()

When I spinup the server node @@8 does exist with the player_1 node under it. On the client side player_1 is under node @@14

Kehom commented 3 years ago

Typically nodes with those names are dynamically created through code without an explicit call to set_name() which leads me to assume you are specifying a dynamic node as parent for the player_* nodes. If that is the case, please ensure you are correctly setting the name of that parent because the path to nodes performing remote calls must match on server and client.

croxis commented 3 years ago

I am not explicitly manipulating the player nodes or player_data (unless it is passed as a parameter and I forgot about it).

I just double checked and the script for both @@8 and @@14 is keh_network/network.gd I added set_name('test') in _init and that resolved the problem!

Kehom commented 3 years ago

While I suspected you were talking about the automatic player_* nodes I was not entirely sure. OK, then there is something with the process related to the instantiation of the network.gd singleton. Since you are using the dedicated server as template, I will place the snippet that I believe will correct things. It should be in the loader.gd file, within the _ready() function:

var netclass: Script = load("res://addons/keh_network/network.gd")
network = netclass.new()
network.set_name("network")

var gstateclass: Script = load("res://shared/scripts/gamestate.gd")
gamestate = gstateclass.new()
gamestate.set_name("gametate)"    # This one may not be necessary, but doing so for consistency

# At this point the tree is still being built, so defer the calls to add children to the root.
root.call_deferred("add_child", network)
root.call_deferred("add_child", gamestate)

If this works then I will have to correct the tutorial as well as the reference material. By the way, the string within the set_name() function can be anything really, as long as it is the same in the server and in the client.

croxis commented 3 years ago

That fixed it! Sorry about the lack of clarity. Parenthood makes it hard to focus on things x.x My only guess is that when I implemented vr on the client, extra nameless dynamic nodes are being created. Now I know what to look for!