Search Unity

Feedback [1.0.0-pre.15] Streaming ghost entity prefab

Discussion in 'NetCode for ECS' started by optimise, Feb 11, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Currently when server try to spawn a ghost entity and if client haven't load ghost entity prefab into subscene, you will get invalid ghost error and the game will fail to work properly. I think this limitation need to change to make unity user life easier and also enable large scale game that will always need to stream in and out ghost entity prefab super fast. You will need to do a lot of ugly if check if still having this limitation
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    We support this scenario already. And can be fixed using the Loading flag on the GhostCollectionPrefab.
    The server will never send ghosts for which the client hasn't ack that he loaded the associated prefab.
    We don't show how to use this in our samples. But one that show how to do that will be available in the near future.

    If you want to expand more on what are you actually want from that feature or your intended use case (at the moment) is always appreciated.
     
  3. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Basically I want as auto as possible that dots netcode automatically handle it for me. At server I spawn a ghost entity but at client I haven load the corresponding ghost prefab entity yet, client won't get invalid ghost error and then stop working properly. Instead client will wait until corresponding ghost prefab entity loaded then ghost entity will spawn at client. So this entire process is automatically handled by dots netcode that I dun need to write any single line of code to make it work.

    I guess it's not supported at 1.0.0-pre.15 release yet?
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    It is already somewhat working like this, the only missing piece is that the handling of the loading logic is left to user, since we don't know from were you want to load that prefab (Addressable?, Subscene ?).
    Also there are many options about how to implement this feature too (even without addressable).

    Having something completely automatic still requires some intervention from you. Even supposing there is an event that is telling you a prefab (with some GUID) need to be loaded, we need user intervention for that.
    Sure, it can be as simple as method that schedule a job that load the resource (or another form of resource management). you
    But I see more value in having you guys handling the resource management the way you want, instead of imposing our way to do it.
    We are automating quite a lot with prespawned ghost, for the good and for the bad. And yet, we also let you write you own custom logic for them (you need to opt out ours via define). Because, you know, for the 1e6 cases you handled, for sure there is the one you need that it isn't :D
     
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    It's confirmed by content management team that addressable is not the official way to load things at ecs project and 1.0 release already removed runtime entity conversation. So should load prefab entity from subscene. I will submit a bug report to shows u how it looks like and this simple netcode project already will make editor really easy to keep crashing. Seems like official not yet battle tested with dots netcode.

    So since official proper way is to use subscene then I think dots netcode should implement automatic solution based on subscene. And also same with prespawn ghost u mentioned, official can provide opt out define for unity user to do customization if required but I think it's not really necessary since the only proper way to load is via subscene. No point to customize this part for hard way and also make it slower to load. I will say currently the only official way for ecs project everything is loaded using subscene by design.
     
    Last edited: Feb 13, 2023
  6. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @CMarastoni Alright. You can take a look at IN-32120. Actually nothing really special. Currently with this repro at client if u change logic flow to send GoInGameRequest RPC first before stream in ghost entity prefab and server spawn a ghost, u will get invalid ghost error. I would like official to solve this limitation that at client even ghost entity prefab is not yet stream in, it will not log error and wait until ghost entity prefab stream in and then finally spawn ghost entity.