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()
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.
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.