-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Clarify that high-level RPC methods must be defined on Node-based scripts #11892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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:: | ||
|
|
@@ -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. | ||
| 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| ``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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace with |
||
| helper objects from there. | ||
|
|
||
| Channels | ||
| -------- | ||
| Modern networking protocols support channels, which are separate connections within the connection. This allows for multiple | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is built around" -> "utilizes"