4
« on: April 03, 2019, 01:00:42 AM »
One thing that I've been musing about for a while involves different methods of rendering a custom player character. I'm not overtly familiar with Lua yet, so I'll try instead to talk instead in loose conceptual terms.
Problem: Let's say that you're making an RPG where the main character can be customized - this can include articles of clothing, but also skin tone, hair, gender, faces. Maybe you can even swap out different outfits throughout the game as well, for either cosmetic or plot-specific reasons.
How do you approach this? I have a few thoughts.
Solution 1: Paint a lot of different versions of the same character
If you have the time and energy, this is probably fine. But it's labor-intensive, and a headache if you have to incorporate potentially many animations. It's really jarring for the player to try to pick up a rock, only to have your blue cape turn into a red one, because you're using a fallback animation.
Solution 2: split body parts into components
This is probably less crazy than option 1, in the sense that you're just splitting up pieces and making the game engine re-assemble them on-the-fly. Suddenly your green-girl-haired elf head can be placed on top of a suit of armor, without the need to explicitly build out every permutation of the player's sprite. This still creates a lot of components to graft together, and it could still lead to janky-looking animations, but it could ultimately reduce some work with creating art assets. The tradeoff is that you'll also have to track the custom body pieces that the player set, and keep them.
The other weird thing is that a "hero" would basically be an object consisting of several sub-objects held together a certain way. This would take some trial-and-error to get to render correctly.
Solution 3: use hardware acceleration to color parts of sprites for you
I'm not sure how proven this idea is, but maybe we can reduce the amount of unique body components sprites you have to draw by using the GPU to render color values as parts of sprites. Maybe you actually just have transparent hair styles, for example, and various hair-shaped colored backgrounds could be dynamically rendered behind them. If you do it right, it could look fairly convincing, and allow you to set a bunch of custom color values on a limited set of generic body pieces, assuming you combine this with Solution #2
Anyway, this is where my train of thought is right now. I realize that I'm not actually providing any scripts here, but I'm curious as to whether other creators have come up against this challenge yet, and what their thoughts might be on how to approach the issue. Maybe by kicking around a few ideas, we can come up with some actual scripts.