Godot Version
v.4.4.1
Question
Hi everyone, I am trying to synchronize my pick-up
action across all clients. The Item
I am trying to pick up has a MultiplayerSychronizer
which syncs position
and rotation
. I am unable to understand how to synchronize the parent Node
.
When picking up the item I simply call a function try_pick_up
which is along the lines of:
func try_pick_up(item: Item) -> void:
if player.has_main_hand_item():
return
item.reset_transform()
item.reparent(main_hand, false)
The Item
is correctly synchronized until the time I pick it up. Once picked up by one of the clients it de-syncs (I assumed it was linked to the SceneTree not being identical amongst all clients).
After further investigation at run-time, I indeed confirmed that the SceneTree is not the same between clients. The one client who has picked up the object correctly has the item
under its main_hand
node, but this does not sync for other peers.
I tried playing around with @rpc
annotation, but I have got to admit that I still can’t grasp how I am supposed to use @rpc
at its fullest. Thinking about it I don’t think I should make try_pick_up
an rpc
call, rather sync the parent
of the item
object, but that’s not an option under the MultiplayerSynchronizer
sync-able parameters list. So how do I do this? - I smile not to cry at this point -