Godot Version
4.3 Stable
Question
I am spawning some nodes on a server and replicating them with MultiplayerSpawner. I am having issues replicating on clients.
The intended hierarchy is:
- Crate
-
- Item
-
-
- Item Data
-
The server successfully instantiates this hierarchy. The replicas only produce:
- Crate
-
- Item
The code being ran (from a crate) is:
@rpc("any_peer", "call_local", "reliable")
func _interact(id):
if !multiplayer.is_server(): return
var new_item = item.instantiate()
var item_data = items[item_type].instantiate()
add_child(new_item, true)
new_item.add_child(item_data, true)
There is a MultiplayerSpawner on the crate (which has Item as an autospawn), as well as a spawner on the Item (which has ItemData) as an autospawn.
I am confused as to why the Items replicate as intended, but the child itemdata nodes do not.
Edit:
I have quickly got around this issue by delegating the second add_child
to the child itself.
I am still curious as to where my knowledge of replicas and MultiplayerSpawner failed in the case provided.