Godot Version
Godot 4.2.1 stable
Question
i was doing some testing with multiplayer on godot for my future card game but i was running into weird problems with rpc on the func that creates the client for some reason i get this error
E 0:00:06:0723 Game.gd:108 @ _on_join_pressed(): Trying to call an RPC via a multiplayer peer which is not connected.
<Erro C++> Condition "peer->get_connection_status() != MultiplayerPeer::CONNECTION_CONNECTED" is true. Returning: ERR_CONNECTION_ERROR
<Origem C++> modules/multiplayer/scene_rpc_interface.cpp:467 @ rpcp()
<Rastreamento de Pilha>Game.gd:108 @ _on_join_pressed()
the code says the client is connected but when i try to call the rpc it gives me that error since im still learning im not sure what is happening
heres the code:
func _on_host_pressed():
#host game
peer.create_server(port, 4)
multiplayer.multiplayer_peer = peer
player_1 = 1
_add_player.rpc()
func _on_join_pressed():
#join game
var error = peer.create_client("localhost", port)
if error == 0:
multiplayer.multiplayer_peer = peer
print("client Connected")
var idd = peer.get_unique_id()
print(idd)
handleid.rpc(idd)
await get_tree().create_timer(1).timeout
_add_player.rpc()
else:
print("error while joining the sever error code: ", error)
btw i need to call the rpc on the add_player func for other reasons