Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions tutorials/networking/high_level_multiplayer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ must have the same name. When using ``add_child()`` for nodes which are expected

See further explanation and troubleshooting on `this post <https://github.com/godotengine/godot/issues/57869#issuecomment-1034215138>`__.


The annotation can take a number of arguments, which have default values. ``@rpc`` is equivalent to:

.. tabs::
Expand Down Expand Up @@ -336,6 +337,47 @@ The function ``multiplayer.get_remote_sender_id()`` can be used to get the uniqu
// Process the input and affect game logic.
}

.. note::

Godot's high-level RPC system is node-based. Methods marked with ``@rpc`` should be defined on
scripts attached to ``Node``-derived classes. Defining RPC methods only on non-``Node`` classes
is not supported and may result in runtime errors.

If needed, keep RPC entry points on ``Node`` scripts and delegate logic to helper objects.

RPC methods must be defined on Node-based scripts
-----------------------------------------------
Comment thread
deathtaco1408 marked this conversation as resolved.

Godot's high-level multiplayer RPC system is built around the scene tree and ``Node`` paths.
Comment thread
deathtaco1408 marked this conversation as resolved.
In practice, RPC methods should be defined on scripts attached to ``Node``-derived classes.

Using ``@rpc`` on methods defined only in non-``Node`` classes (for example, plain ``Resource`` or
Comment thread
deathtaco1408 marked this conversation as resolved.
``RefCounted``-based helper scripts) is not supported by the high-level multiplayer API and can
result in runtime errors when calling ``rpc()`` or ``rpc_id()``.

Supported pattern:

.. code-block:: gdscript

extends Node

@rpc("any_peer")
func submit_input(input_vector: Vector2) -> void:
pass

Unsupported pattern:

.. code-block:: gdscript

extends RefCounted

@rpc("any_peer")
func submit_input(input_vector: Vector2) -> void:
pass

If you need multiplayer RPC behavior, keep the RPC entry points on ``Node`` scripts and call into
Comment thread
deathtaco1408 marked this conversation as resolved.
helper objects from there.

Channels
--------
Modern networking protocols support channels, which are separate connections within the connection. This allows for multiple
Expand Down
Loading