godot: MultiplayerSynchronizer is not able to sync some properties from some nodes (ie velocity from CharacterBody2D)

Godot version

v4.0.beta4.official [e6751549c]

System information

Linux Manjaro - Vulkan API 1.2.0 - AMD Radeon RX 5700 (RADV NAVI10)

Issue description

When trying to sync the CharacterBody2D built-in property velocity using the MultiplayerSynchronizer node, first it will not appear as an option in the helper wizard and if I try to specify its path directly it will not work.

image

I checked if this was the only missing property and it is not, for this node all the missing properties from the menu are:

max_slides
slide_on_ceiling
velocity
wall_min_slide_angle

I have checked this is also happening with other nodes like time_left from Timer

Steps to reproduce

  1. In any scene, create a CharacterBody2D node
  2. In the same scene create a MultiplayerSyncrhonizer node (it can be a child of the previous node)
  3. Try to add the CharacterBody2D built-in property velocity to the replication menu, it will not appear.

Minimal reproduction project

DebugProject.zip

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 9
  • Comments: 16 (4 by maintainers)

Most upvoted comments

Adding by path is possible: Screenshot 2023-12-06 at 18 01 12

Screenshot 2023-12-06 at 18 02 55

But then: Screenshot 2023-12-06 at 18 01 45

Fwiw, I am using this workaround for now:

@export var my_velocity := Vector2(0., 0.):
    set(velo):
        velocity = velo  # to set mine
        my_velocity = velo  # to set theirs

and use my_velocity in the code. Note that this doesn’t force updates to my_velocity when velocity changes (eg. if some underlying class does velocity += 7) as doing this requires a couple of lines to make sure the setters don’t keep calling each other infinitely.

As was already mentioned, the issue arises because of non-export properties not available through UI. However, it’s by design, because that’s exactly what export annotation is used for. It’s not for a MultiplayerSynchronizer to decide, for other components, which properties to make available through UI.

I think that’s exactly why addition via NodePath is available in the first place. It’s actually fully working, although a little bit confusing to use. The issue with it appear, because people tend to specify NodePath from a scene root node. While NodePath must be specified from MultiplayerSynchronizer root_path property.

That’s why “player:velocity” doesn’t work, because it’s used directly as path. While “velocity” works, because it’s transformed into proper path “.:velocity”. You can see it clearly via inspecting source .tscn file.

In short, it’s not a bug, but rather confusing UX, which should be specified in docs for MultiplayerSynchronizer.

setup path

This doesn’t seem to be the case for me, whether I type Player:velocity, :velocity, or just velocity when entering the path to the property to sync, it does not work. I have the position synced which I added through the editor, and also an exported variable, and they both sync properly. But velocity for some reason will not work, resulting in errors. When opening the .tscn file directly, it is formatted exactly the same as these other two working properties (“.:velocity”)

EDIT: Very weirdly, after moving around how some things work (as I was working on something else instead of this, as I didn’t see where the issue was coming from) it started working as intended (syncing velocity). The only difference related to the synchronizer node is that there was no longer a script attached to it, but this should have absolutely no bearing on it’s ability to sync the velocity property of the CharacterBody2D to my knowledge…

image image

In addition to updating the docs, it’d be nice if the article about scene replication was updated as well, since it’s still one of the top results when searching for information about Godot multiplayer.

One of the main functions of export annotation is to limit what kind of properties available to the user through the editor. It’s how it’s designed and how it’s used across all components. If component creator decided that property should not be exported, there is a specific reason for it and MultiplayerSynchronizer should not ignore or override it. That’s why MultiplayerSynchronizer respects export annotation, while giving other means to use non-exported properties.

MultiplayerSynchronizer does work with all properties, so it’s not strictly a bug, but yeah, lack of properties in UI is confusing. I think we both agree that it’s at least non-obvious and requires clarification in docs.

Adding by path is possible: Screenshot 2023-12-06 at 18 01 12 Screenshot 2023-12-06 at 18 02 55

But then: Screenshot 2023-12-06 at 18 01 45

I’ve had this exact issue just now. ‘velocity’ is not in the list, and if you add it as ‘Player:velocity’ it will error. However if you manually add it as just ‘velocity’ it will not produce the error and look the same in the Properties list.

I can confirm that this issue is plaguing me in Godot version 4.1.1. I’ve used the same work around, but it’s clearly less than ideal.