How to handle spawning a prefab that has Multiple Ghost components inside at runtime.

I have a prefab of a room that gets instantiated at runtime, this prefab has lots of nested other prefabs, some of them static (which the client also instantiates) and some of them are ghosts.

When I run game both the server and client instantiate the prefab correctly, but then the ghost gets taken out of the hierarchy (since it needs to be a root entity) and that makes it snap to the wrong world position.

How do you handle this specific scenario?

Most of those ghosts are Physics Entities as well, and can be deeply nested - the prefab is large room/ building with multiple levels, and consists of loads of nested prefabs in different depths.

I don`t want the main room/static components to be Ghosts, there is no point in syncing them since they are static and are predicable to generate on both server/client.

But anything dynamic should still be position in relation to the parent entity when spawn.

A solution that is often used for this is to not have the ghosts directly as part of the main prefab, but instead use a “spawner” entity in its place that spawns the ghost when it is created at runtime. This way you don’t need to worry about hierarchy issues when you author it, as the spawner can be placed in any hierarchy you want. When you instantiate it at runtime, it will then be spawned outside the hierarchy.

I see, so if If I understand this correctly, I would replace create custom authoring components for the ghosts that behave as spawners for themselves instead am I correct?

And on the client I would strip these spawner entities out in a system, and the server would spawn them instead - since sync ghosts are gonna be synced anyway from the server.

Is this correct? And thank you for the pointer.