Ghost component does not trigger change filter when write the same data

When the ghost component write the same data like write 1 value to RefRW every time instead different value each time like 1, 2, 3 and etc, it will fail to trigger change filter which is not the expected behavior. The expected behavior should be like regular component will trigger change filter when the component is set to read & write like RefRW.

Hey optimise. If I understand you correctly, this is a limitation of netcode.

  • We can’t (efficiently) record every change version bump for every single ghost chunk, per component, on the server. Tracking this would be costly in both CPU cost, and bandwidth cost.
  • Thus, the algorithm netcode uses on the client is: Detect a change in component value (from the server), then only bump change version for that chunk if the value was actually modified.

I.e. We expected users to mostly want to know when ghosts on the clients were updated with a changed value. We can’t track false positive writes.

Thus, given that expectation, the previous implementation we had was more correct, because you actually pretend there are changes all the time. What you are asking is probagating the information that the server touched a component to the client. That can be possible, but requires a complete different concept (you just want to know if the server wrote on a component). Or better, you just expect that as soon as new data from server this actually change the value, because that is what you are asking.

I see. Technically I no need exact same regular component change filter behavior that will trigger change filter when the component is set to read & write but I would like netcode still able to trigger change filter even I keep writing the same value to ghost component still treat it as new changes like fooComponent.ValueRW.value = 1 that previously set to 1 and now still set to same 1 value will still trigger change filter. Currently I need to purposely add another data field like version with [GhostField] and bump the version value every time when I write the same value to make sure netcode able to treat it as new changes which is not really nice solution and also wasting bandwidth. Will official able to make ghost component able to auto bump change version even keep writing the same value? If cannot, can official create a ghost component api like fooComponent.BumpVersion() to make it able to trigger change filter?

Correct, your approach is the only way to get updates about the server writing to this component but without actually modifying any GhostField values. FWIW: It’ll be delta compressed extremely well.

Note that due to our network model being “eventual consistency”, there is a chance that:

  • Server bumps the value.
  • Client does not receive (due to other ghosts having higher importance).
  • Server bumps the value again.
  • Client receives an update where the version was bumped twice.

This would be almost identical to what you’re currently doing via a BumpVersion byte, so no, unfortunately I wouldn’t expect us to support this via a new API.

Note that - before change filtering was applied - netcode would report that a GhostField component changed every single Simulation step. Therefore, using [GhostField] byte BumpVersion (along with the new change filtering fix) should lead to better filtering than you had previously (at the cost of a small amount of bandwidth).

Thanks for clarify. Btw how netcode handle ghost dynamic buffer? Is that when ghost dynamic buffer increase count or decrease count or clear the entire dynamic buffer will trigger change filter regardless of the value of the data add into ghost dynamic buffer?

For buffers, if the count change, we consider the buffer changed. Otherwise, if any of the element inside is changed, we consider the buffer has changed.

2 Likes