What's a good setup for having a client send data to the host to run a function with said data

Godot Version

4.6

Question

I’m still figuring out Networking and RPCs, and I’ve ran into a potential hiccup. I am trying to on the press of a button by the client send data from that client to the host and then have the host RPC a function for everyone to carry out with the clients sent data. However the method I’m doing this seems a little inefficient.

Normally It’s useful to include code but I think in this case it complicates matters.

Essentially I have the button’s pressed signal activate a function that calls a second function via rpc_id on the host

the second function called by the host then performs an rpc call for the main function I want to do with the data from the client.

(Note I do have my functions set up right for rpc.)

What would be a good way to have say a client send data to a host so they can use it to do a rpc on all clients?

Sounds like you are doing it correctly. Are you running into any issues? maybe posting the code would help, what kind of data are you trying to send?

From the sounds of what you’re saying the current method is fine and the issue I had I’ve solved with a rewrite of some of the functions. Just need to make sure that RPC functions don’t pass objects such as resources. (If I need them get them from within the function not pass as an argument.)

You do want to pass serializable data, “serializable” means it can be converted to a network-friendly format. Objects are not usually included in this format, typically anything with a .duplicate function will fail to serialize, or serialize with quirks; arrays and dictionaries are on the quirky side for example.