jos_valentin
jos_valentinthis hour

2 or more values changed garantee

There is garantee that 2 values (for example 2 Vector2 values) changed in the same Update() call, it will be sync for other clients both at the same time? for example if v1 has a didChanged() with DidChangeEvent.AfterRead, in that callback v2 will be also updated?
9 Replies
kapa.ai
kapa.aithis hour
Hi @jos_valentin. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Normcore does not guarantee that all property change events (didChange) for multiple values updated in the same Update() call will fire together, unless you use the correct change event mode. By default, when multiple properties are updated in a single frame, Normcore serializes all updates once per network frame (~20hz) and groups them into the same packet. However, when these updates are applied on the receiving client, each property is updated one at a time, and a change event fires for each value as it is applied. This means that if you listen to the default didChange event (or use DidChangeEvent.Read), it is possible that not all values have been updated yet when your callback runs. To ensure that your callback sees all updated values after a batch of changes, you should use DidChangeEvent.AfterRead. This mode dispatches the change event after the current datastore update, guaranteeing that all other properties and models have been deserialized. So, in your example, if both v1 and v2 are updated in the same frame and you use DidChangeEvent.AfterRead for v1, then in the didChange callback for v1, v2 will also be updated and you can safely read both new values there. Reference: DidChangeEvent documentation and Common Questions. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.aithis hour
<@391444583034257420> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Mechabit
Mechabitthis hour
ReadAfter is fired after all models and properties have been updated so yes
maxweisel
maxweiselthis hour
they’ll go out in the same packet and fire on the same frame on the receiving side regardless of change event settings
Mechabit
Mechabitthis hour
the old style change event would fire one at a time which was less convenient than the current system
maxweisel
maxweiselthis hour
yeah the new system is definitely more convenient
jos_valentin
jos_valentinOPthis hour
Great answers, thanks both of you 🙂 Now what about using different property types? I mean for example v1 is Reliable and v2 is Unreliable, in that case the guarantee disappears?
maxweisel
maxweiselthis hour
that’s correct they’re sent on different channels
jos_valentin
jos_valentinOP23h ago
Perfect, thankss!

Did you find this page helpful?