Network instance names

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

Hi,

I have started working on a small multiplayer project which has been a fairly painless process up until I have started instancing scenes. What I have been doing is instancing an object, then having the player being able to pick it up (changing parent basically) and then dropping it again. When I let the player drop an object, so that it is no longer a child of a player, the instance name seems to become out of sync. On one client, the name might be “@@Object@5@1” and on the other “@@Object@1@9”, and as such RPCs can no longer resolve properly as it cannot find the correct node.

Am I missing something in how I should handle the instances? I am basically just calling an rpc on both host and clients asking them to instance a new object, which again, works fine up until it has changed parent a couple of times.

My workaround right now is to just append OS.get_unix_time() at the end of the instance name to make sure it is unique, but it seems like an unnecessary step that should be handled internally.

Does anyone know if it is me doing something wrong or if you are supposed to make sure names are unique yourself?

Thanks

Each node object has its own unique id when created and can be accessed with get_instance_id()

Wakatta | 2021-02-28 20:51

Sure, but RPCs are resolved via the node tree path, and I am pretty sure the ids are not synced over the network.

raksom | 2021-02-28 20:55

Yea so i was thinking
Server create node with name + get_instance_id()
Server tell clients to instance nodes with name + get_instance_id()
All parties involved are happy with unique shared names

Wakatta | 2021-03-06 22:34