difference between rpc() and rset()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By phucotaku

can someone explain to me the difference between rpc() and rset(), i have read the documentation about these two functions and i understand how rpc() function works but rset() function that i don’t understand at all, and like that, i don’t either always understand what is rset_config()

See also “Removing RSETs” in this article: Multiplayer in Godot 4.0: On servers, RSETs and state updates

omggomb | 2022-08-16 14:47

:bust_in_silhouette: Reply From: Wakatta

Will try my best to not give too technical an answer.

So An RPC (Remote Procedure Call) basically lets you call a remote function stub of any connected peer/s

# example

#pc 1
rpc("foo()")

#pc2
remote func foo():
    print("foo")

rset() however changes the member value of any connected peer node

# pc 1
extends Node

remote var bar = 1

# pc 2
rset("bar", 8)

And rset_config() is a helper function for rset() as by default you are not allowed to make RPC/RSET calls to un-awaiting peers.

# if remote keyword is not used on pc 1 above
func _ready():
    rset_config("bar", RPCMode.RPC_MODE_REMOTE)