How can I have a singleton custom Realtime Component in scene
I have an instance of a custom Realtime Component syncing data over the network. Here's what I want:
1- When first client connects, it instantiates the Component's model to an initial data state.
2 - When the second client connects, it should detect that the same Component's model's was already instantiated with a default state by the first client, so this second client only has to replicate the state on the scene.
I've done experiments with the
Am I thinking of the sync model lifecycle wrong?
How can I accomplish the desired behaviour described above?
1- When first client connects, it instantiates the Component's model to an initial data state.
2 - When the second client connects, it should detect that the same Component's model's was already instantiated with a default state by the first client, so this second client only has to replicate the state on the scene.
I've done experiments with the
isFreshModel flag inside the OnRealtimeModelReplaced function but, for the second client it seems to be called twice, once when it first connects, and has a default valued currentModel. And then a second time, when it gets the actual data set by the first client. This behaviour seems odd, I would expect the currentModel have the data set up by the first client filled in on the first OnRealtimeModelReplaced call.Am I thinking of the sync model lifecycle wrong?
How can I accomplish the desired behaviour described above?