Hi all!
We are developing a multiplayer game with the following scenes structure:
All the players can connect through lobby and spawn in HUB scene. The HUB contains own ghosts prefabs, thats populate GhostCollection buffers. Next they are going to the battle in forest, desert or other scene. The GhostCollection buffers grows with new loaded prefabs. After battle all return in HUB. The part of ghosts is unloading with battle scene and GhostCollectionPrefab contains Null entity references. If a new one client try connect to HUB - the errors appears in console: “The ghost collection contains a ghost which does not have a valid prefab on the client! Ghost: ‘THE LAST SUCCESSED GHOST NAME’ (‘Entity.Null’).” and disconnects it.
After diving into a GhostCollectionSystem, I came to the conclusion: the client try to preccess some Null ghosts, thats no need in HUB. They was leaved from battle scenes! I can’t clean Null entities from GhostCollectionPrefab cause the GhostCollectionSystem contains some internal fields with indexes to the buffers. And I can’t drop NetworkStreamInGame between unload/load scene, because I have some cross scene ghosts with battle stats and other data…
Could you check the issue and help me to resolve a situation? @CMarastoni
Best regards
And I can’t drop NetworkStreamInGame between unload/load scene, because I have some cross scene ghosts with battle stats and other data…
Just to confirm understanding, removing NetworkStreamInGame doesn’t destroy the ghost server side. It stays there. Reenabling NetworkStreamInGame will make that same ghost reappear again client side, with the same data. Do you need those stats to be streaming while switching scenes? Or would you be ok having that ghost disappear client side while loading scenes and have it reappear again?
Do you need those stats to be streaming while switching scenes?
One ghost controls scene switching status to sync loading proccess. All clients awaiting each other, while loading ghost prefabs in a new scene
But I confused by GhostCollectionSystem behaviour, thats don’t remove unnessesary elements from the GhostCollectionPrefab dynamic buffer after returning to HUB scene, because the new clients haven’t possibility to connect due null entities in buffer.
Removing NetworkStreamInGame will clear the ghost collection. Readding NetworkStreamInGame will repopulate it with the right set of prefabs.
RPCs still work while NetworkStreamInGame is off. Do you need ghosts to be present to sync scene loading? Couldn’t you use RPCs instead?
Sure, I can use RPC and pass battle statistics in some another approach, or preload all the game ghosts in HUB, but the bug in GhostCollectionSystem still exists… Is this a bug, do you agree with me? If yes, then let’s Unity team open an issue.