This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Are RPCs usable yet with custom_multiplayer or am I doing something wrong?

The code is mostly from an example project for Godot 3 that I've modified for 4. The original worked as expected.

The error:

_on_network_peer_connected: Unable to get the RPC configuration for the function "server_msg" at path: "/root/Server". This happens when the method is not marked for RPCs.

The code:

extends Node

var _peer:ENetMultiplayerPeer

func _init():
    custom_multiplayer =
    custom_multiplayer.root_node = self
    _peer =

func _process(_delta:float):
    if custom_multiplayer.has_multiplayer_peer():

extends ""

func _ready():
    var result = _peer.create_client("",5005)
    if result == OK:
        custom_multiplayer.multiplayer_peer = _peer

func _on_connected_to_server():
    print_msg("Connected to server")
    print_msg("Connected peers: %s" % [custom_multiplayer.get_peers()])

func server_msg():
    print_msg("Server says hi")

func print_msg(msg:String):
    print("Client: %s" % [msg])

extends ""

func _ready():
    var result = _peer.create_server(5005)
    if result == OK:
        custom_multiplayer.multiplayer_peer = _peer

func _on_network_peer_connected(id:int):
    await get_tree().process_frame
    print_msg("Client %s connected" % [id])
    print_msg("Connected peers: %s" % [custom_multiplayer.get_peers()])

func client_msg():
    print_msg("Client says hi")

func print_msg(msg:String):
    print("Server: %s" % [msg])
Godot version 4.0 dev
in Engine by (26 points)

IIRC, the net code for 4.0 is still changing, i.e. it's a moving target. Therefore, it may be a good idea to wait on the network code until it's finalized.

1 Answer

0 votes

I have had success by putting @rpc before the functions where I use rpcid(). In your example, I would try putting it before _onnetworkpeerconnected(), or moving rpc_id() to another function and putting the @rpc tag before that.

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.