MultiplayerSynchronizer does not always sync player health

Godot Version

v4.4.1.stable.official

Question

I’ve setup a multiplayer game in accordance to Multiplayer in Godot 4.0: Scene Replication – Godot Engine and have Heroes that are spawned in with a MultiplayerSpawner and where they each have a MultiplayerSynchronizer which syncs properties: Hero:position, Hero:rotation and HealthComponent:health. All properties syncs fine between all peers except for the health which only syncs sometimes. It seems like certain updates to the health “triggers” an update while others does not, can this be the case?

I’ve noticed the following:

  • If the hero step in lava and the server calls the heroes damage method, then the health will not be synced:
    func damage(dmg: float): health_component.damage(dmg)

  • If the hero takes a constant damage in its processed method, then all health updates gets synced (including lava damage mentioned above):

    func _process(delta: float):
    	damage(delta)
    

Attached is the tree for heroes:

has the multiplayer authority been set on the HealthComponent? Seems like the damage function could be RPC’d for better reliablility and less network traffic instead of using a synchronizer

I did not set the authority, I only give authority to the peer on PlayerInput and for the remaining nodes I do not set anything (as the server has default authority).

RPC is definitely a solution! Is it recommended would you say? I was under the impression that synchronizers was more effecient.

Synchronizers are nice and potentially more effecient for simple, consistently updated properties like position and rotation. Syncrhonizers have settings for rarer “When Updated” properties, but I think you’d be better calling the damage function as an RPC rather than only updating the Health variable; in case there is more you want replicated than just an invisible variable.

1 Like

Sounds reasonable, then I will go with the RPC approach and it should be solved! Thanks for your help.