Devlog #5: Syncing the world state
Finally, players can build together. In this update, I implemented player building and destruction into the game, all of course synced across the network. Lovely.
How does it work?
The system is built off of the deterministic nature of the world generation system: from the same starting conditions, any number of clients will always generate the same world. The beauty of this is that I don't actually need to have the server/host generate all the chunks, then send the data to all the clients, as is the case in a certain other block game. Instead, I just need to store the individual modifications made and send those instead.
As an example, when a player breaks a block, in the Bad System it goes like this:
- Player breaks a block
- Server fetches the entire chunk data (32768 blocks)
- Server sends the entire chunk across the network.
- Client decodes the entire chunk (again, 32768 blocks.)
However, in my system it goes like this:
- All clients generate a chunk. Given the same seed, this will be the same chunk. During generation, if any previous block modifications are found these will be applied.
- The player breaks a block.
- The server tells everyone this one block has been modified.
- Clients generate the chunk.
Like all things, this is a trade-off. As you might be able to tell, the second system uses less bandwidth however at the expense of CPU usage. It's more intensive on the processor to have to re-generate the chunk every-time - though to a modern CPU, it's still child's play. However, to me this system is worth it due to the huge amounts of data being saved. This makes it much better suited to the player-hosted architecture used in Build Fight, as I have no guarantee or realistic expectation that the host will be running anything other than a below-average spec PC on below-average WiFi. I think I've managed to strike the right balance here between system and network performance.
Play it now! Build dicks! Etc!
Up next: storing block data, with the primary purpose of being able to destroy blocks gradually rather than instantly.
Files
Get Build Fight Game
Build Fight Game
Status | In development |
Author | peterkcodes |
Genre | Shooter |
More posts
- V0.11.1 ChangelogDec 08, 2023
- V0.11.0 ChangelogDec 05, 2023
- 0.10.1 ChangelogDec 04, 2023
- 0.10.0 ChangelogDec 04, 2023
- Version 0.9.0Nov 29, 2023
- Version 0.8.0Nov 21, 2023
- Version 0.7.0 ChangelogNov 21, 2023
- Devlog #9: New Player & New PlacesNov 06, 2023
- V0.6.0 ChangelogNov 06, 2023
- v0.5.0 Changelog (+ how to play)Nov 01, 2023
Leave a comment
Log in with itch.io to leave a comment.