The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

How do I tell if a function call originated from a local method or remote call?

I have a remote function that I want to call from both sources and execute a different code branch accordingly. Current solution is to have another variable to declare if the call is local when making the call, but it doesn't translate well if I use remotesync function.

Godot version 3.4 beta 4
in Engine by (30 points)

1 Answer

0 votes

this functions of the multiplayer api should help

get_network_unique_id ( ) 
get_rpc_sender_id ( )

the documentation states:

Returns the sender's peer ID for the RPC currently being executed.
Note: If not inside an RPC this method will return 0.

But i dont know if it return 0 when its an remotesync but called localy ... if not you can compare the sender id to the network unique id

by (4,088 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.