Search Unity

[NetCode] Ghost Observables (Proposition, Implementation question)

Discussion in 'NetCode for ECS' started by LazyMan, May 28, 2020.

  1. LazyMan

    LazyMan

    Joined:
    Dec 7, 2013
    Posts:
    26
    Hello everyone!

    After deep digging inside netcode package, i've found that server will send all existing ghosts to all clients connected, with spawn-despawn behavior synced. That's totally fine for a 'small space' games, where all action is taking place inside clamped piece of world. For example - arenas or levels in the FPS-like games.

    But what about large worlds? Yeah, you've got it right: current system will handle all ghosts in sync between all players without any kind of clusterisation. Imagine a PLAYER_1 with translation 0,0,0 - so, why server should care about distant ghosts around (outside of possible interaction bounds)? Or why PLAYER_1 with translation 0,0,0 should receive data about ghosts located around PLAYER_2 with translation 2500, 0, 2500?

    Let's take a look at picture:


    Green dot - Player (Could be ghost) (Connection)
    Red box - Visibility zone. (Rect to fit screen)
    Small boxes - Other ghost objects, like trees for example.
    Black small box - Ghost object serializable only for connection observable by.
    Purple small box - Ghost object serializable only for several connections observable by.
    Blue small box - Ghost object not serializable for any connection.
    All ghosts still exist on server. (Just for simplicity, off course it could be segmented and clusterized for better server performance, etc)

    Looks like PVS (potential visibility set) yeah? - Yeah.

    So, my proposition is: Do not really "spawn" invisible ghosts for client on server side and mark those as "despawned". So, serialization will not happen. And when ghost will switch to "visible" state for connection - current GhostSendSystem<T> will automatically sync it's internal snapshot data to the latest one, because of implementation. Those actions is "marked" with quotes, because i'am talking about fake spawn-despawn behavior for target connection. And because of internal implementation of systems that mechanism could be implemented only once.

    I'll try to do that, while waiting for another fresh release of netcode package.
    Any thoughts, implementation propositions?

    Thank you!
     
    Piefayth and Orimay like this.
  2. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
  3. LazyMan

    LazyMan

    Joined:
    Dec 7, 2013
    Posts:
    26
    I know.
    Yeah, it's usable, but do not solve the main problem.
     
    Last edited: May 29, 2020
  4. Orimay

    Orimay

    Joined:
    Nov 16, 2012
    Posts:
    304
    Also, GhostDistanceImportance doesn't work for me, as my area tiles connect via portals in a non-euclidean manner
     
  5. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    This is the serious problem for me. I'm also developing open-world sandbox game.