Search Unity

Resolved [1.0.8] Ghost relevancy trigger change filter

Discussion in 'NetCode for ECS' started by optimise, May 20, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Every time when client out and in range of ghost relevancy, every ghost components will retrigger change filter when the ghost entity respawn at client even actually no data changes at those ghost components. I know it's by design of default ecs behavior but at dots netcode I think this behavior should change for ghost relevancy to make it not retrigger change filter when out and in ghost relevancy range and no ghost component data changes.

    And also at client when ghost entity is out of range of ghost relevancy and ghost component of the ghost entity changed data then go in range of ghost relevancy again should also not trigger change filter too. I think these two behaviors should be the correct behavior which I think it's bug. Maybe it's good to have 2 ghost component attribute tags to customize these 2 behaviors but I can't think of any concerre use cases that need to keep these 2 behaviors.
     
    Last edited: May 20, 2023
  2. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    306
    On the other hand, I disagree. Leaving relevancy results in the entity getting destroyed and re-entering results in a new entity getting spawned.

    That should trigger a change filter (or at least an order change filter) since I have a lot of client-side only systems that generate relevant presentation data acting only on chunk changed.

    If relevancy does not trigger changed, then the non-synchronized data will not get properly regenerated when the newly relevant entity gets created.
     
    NikiWalker likes this.
  3. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    315
    Yes, this is intended behaviour, and likely will not be changing for this use-case.

    As change filtering is applied on a per-chunk basis, your code should be handling these "false positives" already (although this case is technically a true positive).
     
    Kmsxkuse likes this.
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    I think I really need official to implement ghost component attribute tag called something like SkipRelevancyChangeFilter = true to handle my use case super easy that just solve it with this attribute tag and get best performance since special workaround implementation. Currently I have ghost component to store damage hit by enemy and trigger change filter show at UI but by current netcode design it will keep retrigger UI update even there's no damage hit. Seems like it's really hard to solve this simple problem that I need to implement long u turn ugly workround solution just to make it work and also the solution will bad for performance.
     
    Last edited: May 20, 2023
  5. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    So.. the problem you would like to solve is detecting when an entity is newly spawned (pretty much) and avoid this being detected as "something changed".
    Now, because as soon as soon as the entity goes out of relevancy is despawned and then respawned if become relevant again, we can't inform you with just the ChangeFilter about this two distinct events.

    And you actually already have the correct solution: just add a client-only tag component (IEnableable) that you set to false after the first frame (or at any specific point you mind).
    This is also what we need to do anyway to track when an entity is "Just Spawned" this frame.

    You can also do extra processing work inside the GhostSpawnSystemGroup to mark entities in a certain way and avoid change filter to be propagated.

    Indeed we can have more granularity by specify the "component" behaviour itself (using the GhostComponent attribute), but I would really need to see solid use cases for that, apart UI update (that I can fix in other ways).

    Also, you can easily track these entities with your own ICleanupComponentData, so you can track when an entity is create/destroyed and update/allow UI changes or any other stuff.

    I'm not saying is not useful to have control over that, it is just that is adding extra complexity on the Netcode side, and that may not even then fit/handle all uses cases.
     
  6. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Actually I just realized that I need more granularity by specify the "component" behaviour itself (using the GhostComponent attribute) that I need to support both trigger change filter and not trigger change filter use case.
    1) When character has top head bar, out and in relevancy should trigger change filter to refresh top head bar value if not will just get zero value which is wrong.
    2) When character hit another enemy character will pop up damage UI value but since this ghost component is at character, out and in relevancy will trigger change filter and then pop up damage UI value which is not expected behavior. It should only pop up damage UI value when character damage enemy character.
     
  7. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    So I think you need to manage this yourself, because this granularity are really outside the scope of the change filter or what netcode can provide by default.