Troglodyte In Underbelly: Sleep Sync

Sleep Sync

Jordan Ireland


In the recent development phase, a significant challenge arose regarding refreshing biomes upon player sleep and establishing communication across different scenes. The task involved ensuring that when a player slept in one scene containing a bed, the biomes in other scenes would update accordingly. However, since these biomes were not loaded at the time of sleeping, synchronizing their state posed a considerable challenge. Failing to address this issue would result in inconsistencies between the player's actions and the game world's state, potentially leading to a disjointed and immersion-breaking experience for the player.


One system our game uses is to cap the amount of resources that a biome can spawn. This includes things like limiting the number of super rare resources, like Glacium, to 1-3 depending on the biome. It also has a lower percent chance to spawn, close to 1% only. The sum lets us use a random number that will be in that range so we can go above a 100% total on our spawnable items.


The challenge stemmed from the need to synchronize the state of biomes across different scenes when the player sleeps. To resolve this, I devised a communication system that allows the scene containing the bed to send a signal to other scenes upon player sleep. This signal triggers the refreshment of biomes in those scenes, ensuring consistency across the game world. Additionally, I implemented a mechanism to store and update the state of biomes, even when they are not actively loaded, enabling seamless transitions between scenes. This solution enhances the player's immersion by maintaining coherence in the game world, ensuring that actions such as sleeping have meaningful and consistent effects regardless of the scene's current state.


One issue I was concerned about was loading time when sleeping, as the game would have to respawn upwards of 100 items randomly within our rule set. This turned out to be a non-issue as the code I wrote was very efficient in placing 1000+ items in a small area on the ground and on walls.




Comments

Popular posts from this blog

Troglodyte In Underbelly: Git Issues