Godot Version
4.7
Context and explanations
Hello everyone,
I am currently experimenting with the MultiplayerSynchronizer which is a great node, but has some limitations to consider, especially when it comes to Resource replication.
The scenario is fairly simple. I just want this node to replicate the PhysicsMaterial property of a node, as the server may be required to change it.
My primary goal is to automate this process via replication. I would love to avoid using RPCs for such thing.
I came up with a solution but I am a bit struggling on how to effectively implement it, as it seems a little whacky so far. The idea is that I could make a specialized object responsible of proxying the Resource. By “proxying”, I mean expose properties that are bound to the resource’s properties. That way, the synchronizer will deal with this node, read the properties it must synchronize and just send them through the network.
Here is the two test scripts :
test_multiplayer_proxy.gd
@abstract extends Node
@export var target_resource_name: NodePath
var target_resource: Resource:
get:
if target_resource:
return target_resource
target_resource = get_node_and_resource(target_resource_name)[1]
return target_resource
and test_physics_material_multiplayer_proxy.gd
extends "res://internals/net/test/proxy/test_multiplayer_proxy.gd"
@export var friction: float:
get: return (target_resource as PhysicsMaterial).friction
set(v): (target_resource as PhysicsMaterial).friction = v
As it is a PoC, I am just synchronizing the friction property.
This technique seems whacky because the magic happens within the getters/setters, regardless of the lifecycle of nodes. As a PoC, it does work but I would love to improve the technique so far, especially as it relies on NodePaths which can be tricky to debug over time.
The hierarchy is :

And the synchronizer follows the property that way :
So far it does work.
Question
Is there any better way of doing this? I don’t want to make a huge game so far and the idea would be to keep it fairly simple. This solution proved to be quite handy, because you would not be inheriting every node you would want to replicate, which here would be a complete nightmare.
I would also consider better implementation ideas. I really do not like the NodePath here because it does not help. Would you make a class per resource type and then inherit again to just fetch the resource from the node? That also seems counter intuitive as it would require a lot of inheritance.
I thought of making my own replication system because I have read that the MultiplayerSpawner and MultiplayerSynchronizer were a bit rigid, but I wanted to give them a try beforehand. On top of that, making a replication system for such a simple game would take time which I didn’t plan.
Thanks for your time,
Varonex







