Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tova |
i’m not sure how to retrieve data from server as a client, or rather send data from server to a certain client
on the server side, in script World.gd I have this function, here i spawn a player (and that works fine)
func spawn_player(spawn_pos, id):
var player = Player.instance()
player.position = spawn_pos
player.name = String(id)
player.set_network_master(id)
$Players.add_child(player)
now in that function I want to send data from a global variable “player_list” to the player who just spawned
how would I approach this?
alright I’ve done some research and now I’m even more confused
I can successfully send data from client to server, but I get error if i try to send from server to client
for example:
on my server I have function:
remote func test(t):
print(t)
and from my client I send:
rpc_id(1, "test", "Hello")
and it works fine
but if I put my test function on client, and send:
rpc_id(id, "test", "Hello")
from the server, it gives me error:
ERROR: Node not found: World.
At: scene/main/node.cpp:1381
ERROR: _process_get_node: Failed to get path from RPC: World.
At: core/io/multiplayer_api.cpp:256
ERROR: Invalid packet received. Requested node was not found.
At: core/io/multiplayer_api.cpp:204
Tova | 2020-03-21 17:00
and yes I made sure both client and server have matching nodes
Tova | 2020-03-21 17:01