I have a question regarding character customization, my question is not related to the progamming itself. I can figure that out. But I am wondering if there is someone here with experience in character customization. And if he/she can explain me how this is usually achieved.
We are currently starting with a project, and our clients asked if it was possible to add character customization to the game. I have made a customization screen (drag and drop clothes and change skin color etc.) in the past and this is not the problem. But I never made this work in a game (Where you can run around and do stuff with your customized character).
My main question is: What is the best way to make the customized character work in a 2D game (If you know 3D I am also interested, but this project will be a 2D game). Making a different character with all its animations for every possible combination does not seem like a solution to me. How is this usually achieved?
Feel free to ask me any questions if you do not understand something, and many thanks in advance for any usable information!
Not an expert on the topic and I guess it also depends a bit on how you will construct your characters, but here are a couple of options you might think about:
1. Create a sprite for every possibility. As you can already see, if you are going to have 100 pieces of clothes, this will require 100 sprites with the same animation and such and well.. this is not very viable.
2. Create a base model and "snap" different pieces of clothes on it and make it move with the character. So far example a hat: you (should) know the coordinates of your character, so you know where your head is located, pick the offset on the head and apply the hat on it. How this is properly handled with the animation I'm not sure, but I've seen people do it, so there should be a way somehow
I would think that it depends upon how customisable you mean. For example, if all the hats you allow are similar enough, store each hat image aligned appropriately with alpha in the right places. For each character animation have a full matching set of hat animations, e.g. "character_walking_frame1" matches "hat1_walking_frame1". Combine the two with alpha, ta-da!
If there are possibilities for customised objects to overlap, e.g. your character's optional sword may intersect the optional hat in some frames, you'd need to store depths as well. Maybe not full 3d depths, but layers. For performance you may want to render all character animations to a memory buffer with all their current gear and then just use that dynamic set of animations for animating your character in-game.