#Ghost field changes event from server
1 messages · Page 1 of 1 (latest)
Not very clear what you mean with " than receive it every tick on the client systems?" What are we comparing here? RPCs? Synced ghost fields?
I mean, how do I know on the client that ghostfield has changed?
You can keep a local tracker & sync value to track. E.g. counter or networkTick
do you mean that I need to create a local variable that is a cache of the previous value of the field?
Correct
You could probably also try use ChangeFilters, but that might give you false positives.
oh, thanks, now I do the same, due to the local cache, however, this does not eliminate unnecessary iterations on entities
Try query with change filter on the component.
i will try, but as you say, this might give false positives, so is it worth it?
Simply combine them
It's easy to test
well, I didn't think about it, thanks again, you're helping me out
no you can't, you have to track value changes on your own if you need that. Change filter is one way to broadphase those
hmm i'm a bit confused then, so can i use change filter to track ghost field changes or not?)
change filters are per chunk
so 1 entity out of 128 changed here - all entities get triggered on change filter
oh, well yes, it seems to be a problem, well, it turns out that the only way to optimize the logic is to check the ghost field in runtime and compare it with the cached local variable of the ghost component?
kinda
most of the time this doesn't actually optimize btw
ECS usually is not working well with reactive patterns
but systems that are triggered by a change in the ghost field can potentially have heavy logic and the ability to not process it every frame, this is optimization, isn't it?
well, it depends
either way
serialization on server side works exactly like this
tracks change filters as broadphase
and then does field comparison
field by field
finds out which ghost fields changed, and serializes them for networking
and it's fairly performant (but super complicate to implement)
yep, and this is crutch
static ghost's ghostfields aren't supposed to be included in any snapshots after the first one unless a field changes i thought? It was my understandind that static didn't mean never changes