Custom Model Sync
how do i know when the latest values of a custom model is completely synced on load?
3 Replies
Hi @Ryan Green. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
In NormalVR, when a
RealtimeComponent
is first created, it starts with no model. Normcore populates it once we have successfully connected to the server (or instantly, if we're already connected) and calls OnRealtimeModelReplaced()
to provide us with a copy of it. This is the point at which you know that the model has been loaded and is ready for use.
However, if you want to know when all updates have been applied to a model, you can use RealtimeCallback
. Normcore serializes all updates once per network frame (~20hz) and groups them into the same packet. When model updates are applied, they’re applied one at a time, and a change event fires for that value. However, it’s possible the other values from that packet hadn’t yet been applied. In order to get an event that fires once all updates have been applied to a model, use RealtimeCallback
.
Here are the relevant knowledge sources:
- RealtimeComponent subclass (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass)
- RealtimeModel updates (https://normcore.io/documentation/room/common-questions#sometimes-when-i-log-the-values-on-my-model-from-inside-of-valuedidchange-not-all-the-values-that-i-set-on-another-client-update-when-are-updates-sent-out-and-how-are-they-applied)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@337874773742845953> kapa.ai is still learning and improving, please let us know how it did by reacting below
if you are joining late the latest model values will be ready with the OnModelReplaced event or by Start() on a spawned prefabs