Customer device not updated (Multiplayer)

Godot Version

Godot Engine v4.2.2.stable.official.15073afe3 - https://godotengine.org

Question

I’m making a multiplayer game and I’ve put a button so that the admin player can restart the game, but the client doesn’t restart the game and receives errors that I can’t figure out, what am I doing wrong?:

func _on_start_again_pressed():
	start_again.rpc()
	
@rpc("any_peer", "call_local")
func start_again():
	var scene = load("res://Menues/Games/Online/Party/party.tscn").instantiate()
	for i in get_tree().root.get_children():
		if i.name == "Game":
			i.start_game()
	self.queue_free()
func start_game():
	var scene = load("res://Menues/Games/Online/Party/party.tscn").instantiate()
	#get_tree().root.add_child(scene)
	add_child(scene)
	Transition.transition_ms.play("Start")
	if lobby != null:
		lobby.queue_free()

Can you show the scene-tree of your party.tscn?

try to do add_child but with force_readable_name:

add_child(scene, true)

The synchronizer needs the same path for every client, so you have to give the parents of the synchronizer a readable_name so its equal on all clients

Now only the client is updated, and has an error:
“get_cached_object: ID 2 not found in cache of peer 1.”

is it a game-breaking error?

no, it’s repeated as long as the game is running

And what do you mean by “only the client is updated”?

Only the client seems to instantiate the new scene, and the server doesn’t move visually. I added print(multiplayer.get_unique_id()) in start_game() and start_again() . So normally the output should show the server and client id twice, but it shows the server id once and the client id three times.

This code works:

func _on_start_again_pressed():
	start_again.rpc()
	
@rpc("any_peer", "call_local")
func start_again():
	var scene = load("res://Menues/Games/Online/Party/party.tscn").instantiate()
	#for i in get_tree().root.get_children():
		#if i.name == "Game":
			#i.start_game()
	self.add_sibling(scene, true)
	self.queue_free()

But to really correct the problem, my upnp function was not called up.
Thanks for your help !
Thanks to you, I’ve discovered the add_chile and add_sibling function options.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.