I'm making a school-based sandbox adventure game in Unity. I need a lot of NPCs with different apperances. I dreaded this since I don't have fun doing art and it is usually the reason I end up becoming burnt out of projects.

My solution for this was to segregate parts of the characters by color. The skin being green, hair being blue, shirt being red and trousers/leg wear being yellow. Then, I would use a shader to change these colors to something else.

The result is this sprite sheet:

Some weird students with the Very-Normal-Paper-Bag-Boy

and the ability to easily change the apperance of my NPCs to make them look different from eachother but there's still an issue.

A lot of the characters have the same hair style etc. Not to mention when I make a new hair style for a female, I have to then draw that style 3-4 more times for the different combinations of clothes.

The solution for this that would work ideally would be a modular apporach. I would only need to draw the sprite once and just swap out different clothing combinations. I have attempted this before but the main issue that kept on coming up was the different sprites not lining up, especially when changing the different sprites.

The art style is pixel art so they have to line up perfectly to look nice. How should I go about doing this to ensure I can fit every sprite together perfectly, no matter the combinations I choose?


1 Answer 1


In order to solve the problems of parts not lining up, you would need a way to specify where the joints are. That is, you will need to build an kind of tree, where each node is a part of the body and specifies the positions of the other parts. It would soft of a...


Unity has a system of skeleton bones and joints that - although it is intended for 3D - should be useful for this purpose. And if they weren't, there are third party solutions such as Sprites and Bones which is intended for 2D.

You rig the skeleton to your sprites, which allows you to animate it. Sure, you won't be doing skeletal animation - at least not to begin with - yet having joints and having parts be transformed (translated, etc.) at those joints is precisely what you need.

Alright, alright, you do not have to use those tools. If you want to stay close to the code, you can specify the joints and pass them to the shader either as part of a texture or a uniform array, and then in the shader you will be able to use the coordinates to offset the positions of the parts.

  • \$\begingroup\$ When I attempted this before, I DID specify where the sprites would be. A separate object for the head, torso, legs and hair. I would line them up for one, but when switching the hair, it would cause a gap on the head somewhere but not for all of the hair styles. \$\endgroup\$ Jun 21, 2019 at 20:43
  • \$\begingroup\$ @Ducktor I have no idea what went wrong. Can you add a screen capture of the problem you describe? - I am thinking that if we are talking of a 1 pixel problem, it could be a rounding error somewhere in your shader code. \$\endgroup\$
    – Theraot
    Jun 21, 2019 at 20:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .