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
-----------------------------------------------

Godot's high-level multiplayer RPC system is built around the scene tree and ``Node`` paths.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is built around" -> "utilizes"

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be edited to be active voice?

High level multiplayer API does not support using @rpc on method defined in non-Node classes (for example, plain Resource or RefCounted-based helper scripts). It can result in runtime errors when calling rpc() or rpc_id().

``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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace
"If you need multiplayer RPC behavior"

with
"To implement RPC behavior"

helper objects from there.

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