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

multiplayer.get_remote_sender_id() returns 0 in an rpc after 'await' #86719

Closed
Blue64537 opened this issue Jan 2, 2024 · 3 comments · Fixed by #87610
Closed

multiplayer.get_remote_sender_id() returns 0 in an rpc after 'await' #86719

Blue64537 opened this issue Jan 2, 2024 · 3 comments · Fixed by #87610

Comments

@Blue64537
Copy link

Blue64537 commented Jan 2, 2024

Tested versions

v4.2.1.stable.official.b09f793f5

System information

Godot v4.2.1.stable - Ubuntu 22.04.3 LTS 22.04 - X11 - GLES3 (Compatibility) - Mesa Intel(R) Graphics (RKL GT1) () - 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz (16 Threads)

Issue description

In multiplayer, during a remote procedure call (RPC), I noticed that multiplayer.get_remote_sender_id() gives inconsistent results after a line with the 'await' keyword (or at least results that are unexpected to me.)
After a line with the await keyword, the result of multiplayer.get_remote_sender_id() is 0, instead of the actual remote sender ID. Before the line with the await keyword, it gives the sender ID just fine. It seems that after await, if forgets that it's in the rpc?

@rpc("any_peer", "call_remote", "reliable")
func example_rpc():
	print("1. Received from: ", multiplayer.get_remote_sender_id())  # An ID like: 134295262
	await get_tree().create_timer(0.1).timeout
	print("2. Received from: ", multiplayer.get_remote_sender_id())  # Always 0

Maybe this is the expected behavior, but in that case it should maybe be added to the documentation?

Steps to reproduce

Start two instances of the MRP (below). In the first instance, click the server button (which starts a server). In the second, click the client button (which starts a client, connects to the server, and executes an RPC on the server). The RPC is also shown above. Before the line with the await keyword (which awaits a timer) the correct ID is shown, but after the await keyword the ID is incorrectly given as 0.

Minimal reproduction project (MRP)

MRP.zip

@AThousandShips
Copy link
Member

@AThousandShips
Copy link
Member

AThousandShips commented Jan 2, 2024

Now this is partially to be expected I'd say, the function to get this value depends on the method being called right now, and will be updated, it will no longer be valid after a delay

This should probably be documented, but there's no way to avoid this as it's a thing that's temporary

The documentation says:

Note: If not inside an RPC this method will return 0.

And this isn't obvious, but being inside an RPC in this case means it has to be the same time, without await, this should be documented more clearly

@Blue64537
Copy link
Author

One or two sentences in the documentation would indeed be very helpful. It would definitely have helped me troubleshoot this faster!

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

Successfully merging a pull request may close this issue.

3 participants