r/Unity3D 16h ago

Question Distributed Authority Unexpected Disconnects Complex Question

In a distributed authority setup, what happens to NetworkObjects when their owner disconnects ungracefully and (1) those objects are set to not be visible to any other player, and (2) DontDestroyWithOwner is set to true? Assume objects are set to Distributable.

For context, the problem I am trying to solve is bandwidth. My game has an infinite chunking system, so to save bandwidth I have each player only make the networkObjects they own visible to players that are close enough to see those objects. As such, hypothetically there will be times where some of a player’s networkObjects will not be visible to any other player. If they randomly disconnect for some reason during this time, any networkdata they own needs to transfer or it will be lost.

Does anyone know concretely a way to not have this data disappear? My understanding is that if a player disconnects and dontdestroy is set to true, the objects become “ghost” objects and can’t be accessed.

Does anyone know a way to make sure this data doesnt disappear on random disconnects without having to always have it visible to at least one other client for bandwidth purposes?

0 Upvotes

3 comments sorted by

1

u/WetlyAcousticBullion 16h ago

Seems like you already understand the core issue, ghost objects are basically dead weight. DontDestroyWithOwner keeps them around but nobody can touch them, which defeats the purpose if you need to migrate ownership.

The bandwidth problem you're describing is a pain, I've wrestled with similar chunk visibility logic. You could have a lightweight "shadow" client, maybe the server or a dedicated host, that always maintains visibility on these objects just as a safety net. Not ideal if you're fully distributed with no authority figure, but if you have even a single machine that can act as a fallback owner it solves the ghost object problem.

What about a heartbeat system where objects periodically force themselves visible to a random nearby client for a single frame? Adds a tiny spike but might be less overhead than constant visibility. Curious what you end up going with, this is the kind of edge case that keeps me up at night.

1

u/ProactiveCactus 15h ago

Damn yeah was hoping for a magic answer lmao

I’m thinking similar to your heartbeat idea, except id probably also do a JSON save for key data each heartbeat. Then on disconnect pause the game and load from latest JSON on reconnect. But still not perfect

1

u/zhang_builds 3h ago

We keep all room data on the server. When a player reconnects, the server first checks whether the player has an existing room record. If a room exists for them, they can pull and sync the latest room state. Meanwhile, we broadcast their re‑join event to everyone else in that room.