Recently I just tried prespawn ghost feature but doesn’t work properly that the ghost component that marked with GhostField tag failed to sync data between client and server. I believe my setup is correct but correct me if I’m wrong. I setup it by putting ghost prefab into subscene and convert to ghost entity to make it available at both client and server world to have the same ghost prefab. I found that at subscene after converted to entity, it will have 2 almost the same ghost entity that 1 ghost entity with Prefab tag component and another ghost entity with Disable tag component. When go in game, the ghost entity with Disable tag component will remove Disable tag component.
yes, this is the intended way they work
until the client connection is not marked as “in game” the prespawned ghost are not made available and synched to the clients
Do u mean put StreamInGame tag component into client connection entity right? I believe I setup properly because if I change to manual spawn ghost entity, it’s working perfectly. I think there’s bug at prespawn ghost feature.
The prespawned ghost must be a prefab. It cannot be an GameObject in the scene with a GhostAuthoring on it. That is to supported IIRC. But I will double check.
We have a specific unit test for the prespawed ghosts and they have been used for many other samples as well. So it is quite a surprise that something is off. But will double check.
Can you share your simple project?
Currently I reproduce it at production project. I will let u know if I able to reproduce at simple project.
Alright. Now I found that it’s caused by the setup at my side and now it’s working nicely but still I found a bug. At subscene, the first ghost I added it will add Disabled component but when I add second ghost it doesn’t add Disabled component anymore. I think this will bring unexpected behavior as the expected result should be no matter how many prespawn ghost u added it should add Disabled component to all the prespawn ghosts.
The disable component is added to all prespawned ghosts in the sub-scene. It is added at conversion time. I tested up to hundreds in the same scene and they usually work pretty fine.
What are you doing when you add the ghost to scene ? Also could you please share what you did in your previous setup that was causing issues?
I just tested at a simple project and it’s 100% reproducible at 0.51.1 release. Just like what I say at previous post. When u add second and the following prespawn ghost at subscene, no matter what only 1 prespawn ghost can get Disabled component. I guess 1.0 release already fix the issue but not yet backport the fix to 0.51.1 release yet. Let me know if u can’t reproduce the bug at your side with 0.51.1 release. I can provide you small repro project.
mmm… is this happening for live-converted sub scene (opened) or also for closed ones?
I will double check in 1.0 as well. thanks for reporting this. We will add a backport fix in case
It’s also the same result for closed ones.
So I think now I understood what happening.
Question: are the pre-spawned ghost all in the same position?
If they are, then it cannot work. One of the requirements for prespawned ghosts is that they must:
- not overlapping (same position)
- have the same rotation (if they are overlapping).
We forced that long time ago and make it a requirement. The real problem though is that we don’t actually log any error or warning about it so the net effect is that:
- The overlapping ghosts (apart the first, int random order potentially) is not disabled
- The overlapping ghosts (apart the first, int random order potentially) are not replicated.
The fix is to always make their position or rotation (if they overlap) different.
We will probably relax that at a certain point, but for now this is how it work.
This is the result if I put 4 asteroids prefabs in the scene.
2 of them are overlapping, 2 not.
And this with all of them not overlapping
(the hierarchy mode is showing the Runtime state)
I see. I think current implementation didn’t take the ghost that without Translation, Rotation and LocalToWorld components into account. The use case for this ghost is it’s kind of global logical ghost that will always available at both client and server but it doesn’t need to update position/rotation.
Btw what’s the reason behind it to do this requirement?
The pre-spawned ghost needs to have a unique determistic hash / guid inside the scene so that they can be match on the by server and client.
The hash is calculated by using the translation and rotation (that was the original implementation).
I do think It is possible to lift the requirement but we need first to have a very deterministic way to assign the ordering of the pre-spawned ghost in the scene at build time (any type of build and platform).
We didn’t invested time on it yet. But if there are good and reasonable use cases we are making hard to do or breaking, please share more about them.
For now currently the only use case I have is just global logical ghost. Btw will pre-spawned ghost that has no Disabled component get any issue? Currently my project have tat but so far I haven see any issue yet.
If they aren’t disabled, they will not work as expected.