Skip to content
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

rpc and rpc_id fail when argument is PackedVector2Array #64623

Open
jjanella opened this issue Aug 19, 2022 · 4 comments
Open

rpc and rpc_id fail when argument is PackedVector2Array #64623

jjanella opened this issue Aug 19, 2022 · 4 comments

Comments

@jjanella
Copy link

jjanella commented Aug 19, 2022

Godot version

4.0.dev (462bb3b)

System information

Arch Linux - I dont think this is an issue with my computer but i can provide logs/more specs if nessecary

Issue description

As the title says, trying to send a PackedVector2Array as the argument over rpc or rpc_id will fail. I work around it by packaging the PackedVector2Array inside an array and unpackaging it on the client side.

Steps to reproduce

Put this code in a multiplayer game. Have a client or server run it. Nothing happens or it crashes without explanation.

func send_data():
	rpc("sync_points", $Line2D.points)

@rpc(any_peer, unreliable_ordered)
func sync_points(points):
	$Line2D.points = points

Minimal reproduction project

Project: Every time a client connects every client gets another triangle on their screen. For it to work, host and client need workaround checked.
rpc_tests.zip
Issue with the zip but a different one was provided by gongpha below.

@jjanella jjanella changed the title rpc and rpc_id silently fail when argument is PackedVector2Array rpc and rpc_id fail when argument is PackedVector2Array Aug 19, 2022
@Calinou
Copy link
Member

Calinou commented Aug 19, 2022

@jjanella Please upload a minimal reproduction project to make this easier to troubleshoot.

PS: Code blocks should use triple backticks like this (with an optional language name for syntax highlighting):

```gdscript
code here
```

I edited your post accordingly, but remember to do this in the future 🙂

@jjanella
Copy link
Author

jjanella commented Aug 19, 2022

rpc_tests.zip
Issue with the zip but a different one was provided by gongpha below.

Project: Every time a client connects every client gets another triangle on their screen. For it to work, host and client need workaround checked.

@gongpha
Copy link
Contributor

gongpha commented Dec 20, 2023

I can't reproduce the error in Godot 4.2.1.stable and can send PackedVector2Array successfully. But instead, I got an error from sending an empty PackedByteArray.

E 0:00:06:0231   _process_rpc: RPC - 'Node(server.gd)::sync_points': Method expected 1 arguments, but called with 0
  <C++ Source>   modules/multiplayer/scene_rpc_interface.cpp:290 @ _process_rpc()

@jjanella Seems you added an empty zip file. So I will add mine instead.

base.gd

extends Node
class_name Base

func _ready() -> void :
	multiplayer.connected_to_server.connect(func() : print("Connected"))
	multiplayer.peer_connected.connect(_peer_con)
	
func _peer_con(peer : int) -> void :
	var data = PackedByteArray()
	sync_points.rpc_id(peer, data)
	
@rpc("any_peer", "unreliable_ordered")
func sync_points(data) -> void :
	print(data)

server.gd

extends Base

func _ready() -> void :
	super()
	print("server")
	
	var peer := ENetMultiplayerPeer.new()
	peer.create_server(5555, 2)
	multiplayer.multiplayer_peer = peer

client.gd

extends Base

func _ready() -> void :
	super()
	print("client")
	
	var peer := ENetMultiplayerPeer.new()
	peer.create_client("127.0.0.1", 5555)
	multiplayer.multiplayer_peer = peer

@jjanella
Copy link
Author

jjanella commented Jan 1, 2024

That is odd that it was empty, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants