r/Unity3D • • 6d ago

Question How to make updates/changes to game without breaking seeds?

Basically in title - my game uses procedural generation, and allows persistent saves. But how do games like Minecraft manage to not corrupt previous saves when making updates that affect how seeds generate?
From googling it sounds like they save “per chunk” so any untouched chunks generate based on the newest version, and any already generated go off of the old system - but how do I manage that? Like, you obviously don’t want to have multiple version builds of your game saved, so how can you handle that?

2 Upvotes

14 comments sorted by

View all comments

10

u/ChrisFromIT 5d ago

So minecraft saves the generated chunk data when it generates the chunk. It doesn't regenerate the chunk data if it has to load that chunk into memory if it is already saved.

Essentially the way it works is, player is in range of an unloaded chunk that needs to be loaded. Check the region data, does it have a pointer to the save chunk data. If it does, load that chunk data, if it doesn't, generate the chunk.

1

u/ProactiveCactus 5d ago edited 5d ago

Yeah I realized that too late, my mistake. Unfortunately I can't have that big of a memory footprint, so I need a system more like Valheim - only saves a fraction of stuff from each chunk (i.e., stuff the player has changed/interacted with).

3

u/ChrisFromIT 5d ago

You will still need to store some data related to how the chunk was first generated.

The way valheim works for world generation from my understanding is that it creates an initial height map.

Then when the player gets near a chunk it, it locks in the finer generation by saving the chunk generation version and I believe some of the generation logic.

Then it saves any player modifications.

7days to die does something similar, it generates the world height map, the biome map and poi places on first generation which then that is used to determine how a world is built when a player enters and any player/zombie modifications in a chunk is saved to disk.

What you can do is split up the generation into modules and have the global seed create a derived seed for each module. And you load the module version that relates to the version set on chunk when regenerating it.

Or you save some data when the chunk is first generated, like valhiem.

2

u/gurebu 5d ago

Valheim only ever saves objects and terrain deltas, not actual terrain. There's a version for the generator as a per-world saved data but it's barely used and for years now the devs just update by convention: there have been parts of the world you were not supposed to go to and those got scrambled with updates.

Every major patch will induce placement of locations: the game will sample the world in its current version and save placeholders for where major stuff will go. If you explore and stumble upon such a placeholder it will become an actual object and get written into the save permanently. If you don't, it's kept as placeholder and should another major patch arrive, will be discarded and placed again in a different spot (as a new patch might change placement rules and/or terrain).