This past week have spent a great deal of time on fixing some synchronization issues we had with chunk loading. Chunk loading is what happens when the player enters a new area on the map, and the following happens:
- If the server isn’t simulating the chunk (it isn’t loaded on the server), the chunk is loaded into server memory from a save file and everything starts “moving”.
- The server server sends the chunk to the client(s) using fragmentation (little pieces at a time).
- Once the client has received the entire chunk, the client spawns all the graphics into the world for the player to see.
- The server is notified and starts sending update packets so everything starts moving on your screen.
Here we can see before & after a few additional chunks have been loaded.
The problem we had was that while we were in the process of loading or unloading specific chunks, NPCs (zombies) could decide to walk over to another chunk. This messed up the chunk loading process royally, so we ended up with “ghost” zombies that could not be interacted with. This turned out to be pretty tricky, but by carefully keeping an eye at the state of every single NPC, and make sure everything was executed in the right order over the network, we got increasing control over the phenomenon. It got solved right before the weekend, and everything seems to work perfectly!
XML – The path to awesome mod support
Since November, when we have been adding content to the game, we have organized our data in such a way that would make it easy to open up support for people who like to make mods. For those who do not know, a mod (modification) is a user made change or expansion on the game which are generally distributed for free, and available to everyone who owns the game. We have seen the thriving modding communities of other games, and decided that it is something we want to strive for.
The past few weeks, we have taken one of the big steps towards this. We have been converting all our content data into XML file format. XML is a way of packaging data in text documents in a way which is both readable by humans, as well as by the game. Using these XML text files, both we, and anyone who would ever want to make additions to the game (for modding), can do so without writing any code.
Here is an example of XML defining an enemy. It tells the game that I want an Enemy type with specific stats. If I wanted to, say, make the game harder, I could simply increase the maxHealth number, and the next time I start up the game, the big zombies will be harder to kill.
We intend to expose as much as possible to these XML formats, to make it possible to do as much as possible without needing coding experience. Here is an example of how you decide which animations should be played when the NPC perform different actions.
In this example, we swap which mesh and texture material a specific weapon-modification should use by only changing two lines in the XML file.
It should be added, that for more complex mods, that wish to expand with functionality that is not supported by the core game engine, will need you to write custom C# code. This is only natural though, since it is impossible for us to cover every aspect of content creation anyone could ever think of. We will however do our best to make it as convenient as possible to create a wide variety of content!
The game will be able to load 3D assets, animations, sounds, textures, using this system as well. We have not quite gotten to that part yet, but our current plan is to use Unity asset bundles to import assets like this. You import all the assets into Unity, and then build a “graphics pack” of sorts from it, which you then can use by writing the file names of your assets in the XML file. Pretty smooth if you ask me!
That is all for today. If you have any questions or suggestions, please feel free to contact us at firstname.lastname@example.org or join our discord community at https://discord.gg/jXJyxUh . We love a chance to talk about our work!
Hope you liked the write up. Here is an bonus image of our pathfinding debug tool!