I have written a little bit about how we handled modding in our game a long time ago. We encountered an issue that we just fixed in recent builds and that’s what I’ll talk about in this post.

The Problem

We originally had two ways that we handled our sprites. One uses individual images which the game then packs into one big atlas. This is the one used by the game’s items and objects like trees, walls, floors, tables, chairs, chalkboards, etc. The other one uses a pre-made spritesheet which contains all the characters in the game. This includes the faces, heads, hairstyles, bodies, special characters, and animals.

This is the pre-made spritesheet.

The pre-made spritesheet has drawbacks that would haunt us later in the lifespan of the game. When we released our modding tools, it didn’t take long for players to make reskin mods. A lot of our mods revolve around changing the school uniform like using uniforms from Harry Potter or My Hero Academia.

The modder would copy this spritesheet then edit the uniform to whatever they like. However, we are also updating this spriteheet when we’re adding new characters. This means that whenever we add something to this image, the modders would also have to update their mods (which most of them don’t and we can’t force them). If not, their mods would be outdated since the new characters are not in the old spritesheet that they used. This leads to bug reports where there are invisible characters like an invisible dog or an invisible lawyer. We sadly have to tell players to uninstall character reskin mods as they are already outdated. This is not good both for players and modders.

Why didn’t we make the characters use individual images instead? Laziness, perhaps. When we started making the game, we were only using spritesheets. I only discovered later that the sprites could be maintained in their separate images and combine them to one big atlas during runtime. However, we only applied this to the game’s items and objects as they would evolve more frequently than the characters. Then the character spritesheet starts to have more characters in it that it has become to look time consuming and game breaking if we change it. It became a technical debt with interest that has already compounded a lot of times that the price became too high to pay.

It came a point where all of our character reskin mods are broken. It’s time to pay the debt.

The Fix

The fix looks straightforward. Just split the images and add them to the combined atlas together with the other items. Well, easier said than done.

One obstacle is that our artist (Ryan Sumo) is busy as he’s the CEO and also acting as the producer. Splitting the spritesheet would be the least of his priorities. Luckily, there are lots spritesheet splitting software, and there’s one that I particularly liked. It’s a Unity editor script. What I really liked about this splitter is I could name each individual sprite before exporting the split images. I need to name them properly so that I don’t need to edit the current mapping by ID. This also lessens confusion. Manually naming each sprite took some days (I was doing this on my free time).

I needed the names used by the current mapping

The script is also easy to read. I was able to hack it to suit the unique needs in the game like I wrote a script that checks if all current mapped IDs have their corresponding exported sprites. I needed to have that assurance as I may have made mistakes during manual naming.

After all the individual sprites are accounted for, I made a script that generates the XML entries which is read by the texture packer, the one that generates the atlas. Then came the arduous task of updating character prefabs and scripts to use the sprite from the atlas. This was like a complete overhaul of character rendering. Like I said, the debt has compounded.

Finally, the last of the fix is to delete the characters spritesheet. This is the best way to know that the game is no longer referencing such asset.

Now What?

All the existing character reskin mods are still broken until the modders update them using the individual images instead. With this new handling, these mods will not get outdated even if we introduce new characters to the game. This also has the benefit of combining multiple reskin mods. For example one mod reskins students and another reskins teachers. In the old way, one mod will overwrite the other depending on installation order. Hence, only one of the mods will reflect on the game. With individual images, these two mods can be installed and both of them will reflect in the game.

That’s all I got for now. I hope this helps if you plan to have modding in your game.