"Losing information" with RPC

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Katsu

Hello Everyone

I am currently creating my own multiplayer game using the Godot High-Level-Multiplayer API and i had the brilliant idea to immediately start without testing around a bit.

Now, the problem is that if I try to instance a new object and then send the instruction over to the clients via an rpc call, the “information sometimes gets lost (it doesn’t instance the object on other clients)” and if i than try to do an rpc call from that object that doesn’t even exist, i get massive frame drops or the game crashes completely.

I tried to fix this by instancing all objects i need, immediately on start of the game but now that i added sword swings and stuff that instance a new object on every action, it really isn’t a viable option.

I am noting: The client and server are in the same project. So if you click the host button you create the server and immediately join as a player (Maybe this information is useful).

I wanted to ask if someone maybe knows what the problem could be.

Thanks in advance

if you do a normal rpc, you should not have any information lost, althought the information transfer might not be instant (it will re-send until the packet arrives)
if you used rpc_unrelieable, i suggest to go back to standard rpc.

i suppose the issue is not in the lost packet, but rather on the scene tree not being the same on both client and server.
I suggest you to run the client from the debug, and use the “Remote” button to see what the scene tree looks like, to check if it is as you expect.

Remember that node names are important: if you create multiple instance of the same scene, Godot will automatically assign a name depending on how many instance there are.
If for any reason (namely lag), the number of instances on the client is different from the server (even for a brief moment), and a new instance is create in that moment, this last instance will have 2 different names on server and client, and will screw everything up.
If this is what’s happening, the solution is to give custom name to the instanced node.

Andrea | 2021-03-09 17:18