multiplayer game crashing

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

im trying to make a simple game wich is a multiplayer version of space invaders (to learn more about networking and whatsoever)
and i ran into this problem:
when i connect to the host the game crashes and an error pops up :
attempt to call function run_server_func on base null instance
here’s my code
in the network autoload:

func call_peer(node_path, function, data):
rpc_unreliable("receive_call", node_path, function, data)

remote func receive_call(node_path, function, data):
    get_tree().get_root().get_node(node_path).run_server_func(function, data)

in the player script:

   func _physics_process(delta):
       network.call_peer("res://entities/Friend.tscn","move", position)

in the friend node(the character the other player is controlling):

func run_server_func(function, data):
if function == "move":
func move(data):
    position = data

thanks for taking a look it means a lot

:bust_in_silhouette: Reply From: unlut

“res://entities/Friend.tscn” is not a path to a node in the scene tree, it is a path to a “scene resource” file which is something different. For example, if you scene tree is looking like this (you can see it at the topleft of the godot editor during editing and runtime):


and you want to access FriendCharacter node from root, than node path would be “Node2D/FriendCharacter”.

thanks for your response i changed it to MainScene/Friend since my scene tree looks like this:

      -Player(Node from wich im calling the rpc)

but the same error pops up
any help would be appreciated

ROBOTOO007 | 2020-09-27 16:48

Is the scene tree same for both games? If yes, try finding error step by step, start by printing children of root node etc.
for child in get_tree().get_root().get_children():

unlut | 2020-09-27 18:50

thanks a lot i tried that and launched the game and now for some reason it works i will never understand this but still thanks so much

ROBOTOO007 | 2020-09-27 18:56

This sometimes happens when you use two godot editors, changes to scenes/scripts/nodes etc is not reflected to other editor but it works when you close/reopen the godot, not sure what is the reason. I also encounter this issue (I would say rarely) when developing a multiplayer game.

unlut | 2020-09-27 19:05