Saving and restoring state from a room

More general question,

I want to have dynamic rooms and then be able to save off the state/synced entities of a room when everyone leaves, then restore that state/synced entities when the room starts up again. My guess is that this would need a simulation server but I’m curious if that is necessary? So this mostly an implementation type question to see what the best route to do this would be.

Hi, yes in a scenario where you wanted to persist some state on a rooms based gameplay, a simulation server would handle this. You’ll need an identifier to connect your state across room sessions. You can pass this identifier as a tag or k/v when you create the rooms through the SDK, e.g. with these options: Interface IRoomsService | Unity Documentation

How would I save the state or is this something the replication server does based on the identifier? Or is there another part of the sdk to serialize out the sync objects?

Hi Michael!

To elaborate on Brit’s answer, there are several options:

  1. Use worlds, then entities set as “persistent” will automatically persist - worlds can also be set to auto-suspend so when nobody is there, they will not consume credits. This is the most native solution.
  2. Use rooms with a separate backend, i.e. enumerate the entities that need to persist in e.g. JSON and save them somewhere with the room identifier you are using.
  3. Anything client-related can be stored in the client’s KV store (see our docs for KV store).

We have room-based persistence (based on ID) in our roadmap as well, but it’s not a priority right now.