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

In Server/Client connections the assigned authority ID given with the "multiplayer.connected" signal is not synced between both parties. #12

Open
person-615 opened this issue Aug 29, 2024 · 5 comments

Comments

@person-615
Copy link

person-615 commented Aug 29, 2024

Using Godot 4.3 Stable

With the "multiplayer.connected" signal, the id given is not synced when using Matcha.

ENet example for control, how it should work:

func join():
	var enet = ENetMultiplayerPeer.new()
	enet.create_client("lobalhost",135)
	multiplayer_multiplayer_peer = enet
	
	print(multiplayer.get_unique_id())		 # Hypothetically prints 80498123

func host():
	var enet = ENetMultiplayerPeer.new()
	enet.create_server(135)
	multiplayer_multiplayer_peer = enet

	multiplayer.peer_connected.connect(func(id):
		print(id)		 # Would print 80498123, synced with the client
	)

How it is currently behaving:

func join():
	var room = MatchaRoom.create_client_room( [HOST ID HERE] )
	multiplayer_multiplayer_peer = room
	
	print(multiplayer.get_unique_id())		 # Hypothetically prints 58129612

func host():
	var room = MatchaRoom.create_server_room()
	multiplayer_multiplayer_peer = room

	multiplayer.peer_connected.connect(func(id):
		print(id)		 # Hypothetically prints 91286332, NOT synced with client.
	)

I have replicated this issue and it is present in an example project.

@person-615
Copy link
Author

Did not mean to close this, it is still an issue. I checked and it occurs in 4.2 as well, not just 4.3

@person-615 person-615 reopened this Sep 6, 2024
@masterthdev
Copy link

I solved this on one of my projects, but it was using an old version of matcha(I don't remember which commit). It was also spamming errors, I don't remember if I fixed that.

I created a branch and copied changes from my project, feel free to have a look: https://github.com/masterthdev/godot-matcha/tree/sync-peer-ids

@freehuntx
Copy link
Owner

Im currently at vacation. I take a look when im back. Sorry.

@person-615
Copy link
Author

**masterthdev ** commented

Late reply, but this works without a hitch on 4.3 stable, thanks

@jlemke
Copy link

jlemke commented Oct 18, 2024

This fix can also work for mesh rooms with some tweaking. I don't know a lot about networking so there might be a cleaner solution, but I changed _on_got_offer() to create a new offer_peer if the offer_id doesn't match the answerer's rpc_id. Then the other peer creates the answer peer since the offer id matches. I also had to change Utils.gen_id() to take in an optional rpc_id, which it would use instead of the peer_id masterthdev added.

edit: still have an issue where it sometimes doesn't seem to answer offers correctly

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

No branches or pull requests

4 participants