You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GDScript allows you to place an RPC annotation on any method of any class you create, whether or not it is derived from Node. You can get as far as running the project and hitting the line for the defined RPC call. When the call is attempted, a run-time error informs you that RPC calls can only be made on methods of Node-based classes. This makes sense, but the documentation and script parsing isn't as explicit. The documentation mentions Nodes often in the high-level multiplayer tutorial, but there is no explicit warning that attempting to call RPC on a non-Node method is not supported. Likewise, you could code an entire interface around Resource-based RPC calls only to find out it isn't supported later during testing.
Steps to reproduce
Create any non-Node class and define a method as @rpc. Use a Node to establish a high-level multiplayer connection, then attempt to rpc() that method. You will get a run-time error, despite the documentation never explicitly stating that would happen and the script parser allowing it.
Minimal reproduction project (MRP)
bad_rpc.zip
You'll have to run test.tscn and test2.tcsn on separate Godot instances. The only indication that you can't call the rpc is a run-time error.
The text was updated successfully, but these errors were encountered:
For a remote call to be successful, the sending and receiving node need to have the same NodePath, which means they must have the same name. When using add_child() for nodes which are expected to use RPCs, set the argument force_readable_name to true.
And:
Each node has a multiplayer property, which is a reference to the MultiplayerAPI instance configured for it by the scene tree. Initially, every node is configured with the same default MultiplayerAPI object.
We could see about adding a check for this annotation in GDScript to throw an error if its in a script that's explicitly not a node, but it might not necessarily be wrong to add the annotation to a generic script, it would depend
Tested versions
Currently using v4.2.stable.official [46dc277]
System information
Godot v4.2.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1080 Ti (NVIDIA; 31.0.15.5186) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)
Issue description
GDScript allows you to place an RPC annotation on any method of any class you create, whether or not it is derived from Node. You can get as far as running the project and hitting the line for the defined RPC call. When the call is attempted, a run-time error informs you that RPC calls can only be made on methods of Node-based classes. This makes sense, but the documentation and script parsing isn't as explicit. The documentation mentions Nodes often in the high-level multiplayer tutorial, but there is no explicit warning that attempting to call RPC on a non-Node method is not supported. Likewise, you could code an entire interface around Resource-based RPC calls only to find out it isn't supported later during testing.
Steps to reproduce
Create any non-Node class and define a method as
@rpc
. Use a Node to establish a high-level multiplayer connection, then attempt torpc()
that method. You will get a run-time error, despite the documentation never explicitly stating that would happen and the script parser allowing it.Minimal reproduction project (MRP)
bad_rpc.zip
You'll have to run test.tscn and test2.tcsn on separate Godot instances. The only indication that you can't call the rpc is a run-time error.
The text was updated successfully, but these errors were encountered: