You pick up many extra challenges when you decide to create your game in three dimensions. Not only are you choosing for your items, props, environments, and characters to now no longer be 2D sprites that your artist can draw in their favorite art program, but you now accept a seldom considered new inefficiency: the fact that there will be parts of your objects that will be created and managed by your game engine unnecessarily. Say what? Okay, hear me out here.
Say your artist (which may or may not be you) creates a rock for your scene. Now let’s just assume they make the complete rock. It isn’t a single sprite, but a collection of polygons with a texture (we won’t get into the intricacies of materials here). If you take this 3D object and rotate it, you will see its outer surface from all angles. This is, of course, assuming your artist didn’t go the super efficient route by leaving out the bottom of the rock, knowing it would be static and the player couldn’t knock it around the level. But this rock has parts of it that are completely useless when looking at it from a particular angle. At any given point in time, when the camera is pointing at the rock, the backside of the rock is there, taking up memory, even though it doesn’t need to. It’s just there. There’s nothing we can do about it. You can walk around to the backside of the rock, and ah, there we go! Those wasted polygons on the rear side are now being put to good use because we can see them! We can touch them! We can bounce things off of their surface… but wait… now the front side is hidden, and those polygons are now taking up the computer’s resources unnecessarily. Dang it!
While we can’t just put a sprite in the place of the rock (well we could, but then the 80’s would call and say they want their cheap game dev tricks back), we can do things to maximize efficiency. If the rock won’t be knocked around the level, we don’t need the bottom of the rock. That’s a few less polygons to worry about. If an entire crashed spaceship is half-buried, its nose sticking out of the dirt, we don’t need to model the entire spaceship, do we? Just the nose. More efficiency has been gained.
But what about our characters? What about games like RPGs where your character gains items, like clothing and armor? You aren’t going to forego the advantage (and ego boost) of wearing your shiny new armor simply because all those polygons that your armor will cover up will waste computer power, are you? Of course not. You’re donning that sucker and slaying 2.5 times more monsters!
But if we don’t do something about inefficiencies in our game, they could quickly pile up. The more ways we have to be efficient, the more efficient our game will be overall, and when we near the shipping date we may have just a few less headaches when the time comes to look for ways to cut down on resource usage.
In addition to wasted resources, hidden polygons on a character pose another problem (pun intended). You see, when you rig and animate your character, it’s going to twist and deform in all sorts of exciting ways. This is great, except it introduces a problem when it comes to your character donning new clothing. The polygons that make up the character’s skin which exist beneath the clothing could poke through (and often do) when the character contorts into a particular posture. For example, you have a human, and this human is wearing a tank top. Well, maybe the animator created walk/run/idle animations. Maybe a jump, dodge, roll, attack, etc. And maybe those animations work just fine while the character is wearing the tank top. But later on in development, the team decides the character must find a long sleeve shirt at some point. Maybe a jacket too. Maybe chainmail, plate armor, or even worse, a tight cycling shirt. Suddenly those awesome animations cause parts of the character to poke through the clothing. You could possibly scale the armor up, but skin-tight cycling shirts may look a bit weird if they aren’t… well… skin-tight.
This is where the Modular Character approach comes in. Not only can we stop rendering wasted polygons, but we can also eliminate the danger of those polygons poking through the clothing mesh our character is wearing at any given point in the game.
Let’s go back to our tank top guy. Let’s say he’s wearing his tank top at one moment, but then he dons a long sleeve shirt the next. His shoulders, biceps, and forearms are now wasted polygons, which don’t need to be seen. Furthermore, they will annoyingly poke through the long shirt sleeves in certain poses. The solution? Remove the arms. By swapping out the character mesh for one that is missing the arms at the location of the sleeves (and in fact the chest and torso as well) there are no polygons beneath the shirt at all!
Wait a minute, but what if my character wants to change out their pants? Gloves? Headgear? Do I need to have a bazillion versions of my character mesh? Well, no.
You create a character that has a few key mesh variables. For example, you can have a character with three main meshes: Head, Arms, and Legs.
Your head may have several versions: Head with a neck that reaches down to the chest (for the tank top)…
…maybe you have a version of the head designed for wearing masks.
You will have several versions of the arms. You will have arms that extend from the shoulders to the fingertips (for the tank top)…
…and arms that consist of just hands from the wrist-down (for long-sleeved shirts).
Likewise, your legs can allow for shorts…
…shorts with shoes…
…and so on.
Then you program your game so that each time your character equips a piece of clothing, that clothing belongs to a certain category. For example, a tank top will be a shirt, and specifically, a shirt of type tank top. Once equipped, your code will check to see what type of headgear your character is wearing, and then choose the head that corresponds to the tank top type of shirt and the whatever type of headgear (or none if it’s not wearing any). Once this code is complete, you’ll have a swapping-out system that is constantly choosing the correct mesh for the head, arms, and legs depending on what clothing you’re equipping/unequipping.
This can be seen in the following video, where I have used a character from Adobe Fuse (free, by the way) animated with animations from Mixamo (also free). Notice my character can run around and perform any action without needing to worry about his skin poking through his clothes because in fact there is no skin beneath the clothes! Kinda creepy when you say it like that.
Is it worth it to go through all this trouble? If you want your character to be able to do different pieces of clothing, I would say yes. It’s a bit of work to get through the coding side of things, but in the end, you have a super efficient system, and you don’t need to worry about skin-tight clothing or scaling up your armor. Because the code can be tedious (and inefficient if you don’t code it smartly) I am creating a tutorial on this very thing. I will be teaching how to create my system in Unreal Engine, including all source code and using all free assets available online. So if you’re interested, send me an email at DruidMech@gmail.com and let me know, and I’ll send you a link to the Udemy course once it’s completed. I’ll have several hundred free coupons, so if you email me early enough you’ll have access to the course for free!
Don’t be lazy when you create video games. You might be an indie developer, but that doesn’t mean you have a license to create crappy games. The more care and time you put into making your games efficient, the more likely you are to succeed and you’ll feel even better about the work you put into it!