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.
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
- In any scene, create a CharacterBody2D node
- In the same scene create a MultiplayerSyncrhonizer node (it can be a child of the previous node)
- Try to add the CharacterBody2D built-in property
velocity
to the replication menu, it will not appear.
Minimal reproduction project
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 9
- Comments: 16 (4 by maintainers)
Adding by path is possible:
But then:
Fwiw, I am using this workaround for now:
and use
my_velocity
in the code. Note that this doesn’t force updates tomy_velocity
whenvelocity
changes (eg. if some underlying class doesvelocity += 7
) as doing this requires a couple of lines to make sure the setters don’t keep calling each other infinitely.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…
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.
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.