Attachment Points
One of my goals with the hair was to have it be a free shape. I wanted the hair to have that sort of variety in shape and size. A limitation with Dynamic Pixel Mapping is that the larger silhouette of the sprite stays the same. If I wanted to change that silhouette, I’d need some way to attach a separate hair layer to the head.
The simplest way to do this would be to have a dictionary that stored the coordinates of where the hair needed to be on each frame of each animation. But that would have to be done manually and unintuitively. I wanted it to be as simple as a couple marker pixels I place while animating that can track where each attachment point is.
That’s when it hit me. The Dynamic Pixel Mapping library works by reading the positions of pixels on a texture and recording them. What if I did something similar. What if I wrote a tool that, given specific colors to look for, scanned each animation for those matching colors in a dictionary, and made those coordinate values accessible by the attachment objects.
I started by establishing colors for my points. The key points I wanted to track were each hand, the head and the hips. For the head, I wanted the hair to be able to tilt with the head, so I used two tracking points, the slope between the two would define the angle the hair needed to rotate. For the hips, I wanted to later add a skirt that followed cloth physics. Those points would define the two ends of the cloth.
I then exported the sprite sheet, making sure the attachment layer was always at the bottom of the sheet.
Then I wrote a script that scanned that bottom row, looking for and recording those pixels, then storing them in an indexed list.
The end format was a list of animations, labeled by name, each containing a list of frames. Each frame contained a collection of six Vector2 coordinates, each corresponding to a specific point.
But overall, it works. When I make a new animation, I just have to add a new entry to the input list, add the texture file and name, run it to recalculate values, and boom it works.
There are some bits I had to work out later. That whole angle between the two points defining the angle of the hair thing required relearning some trigonometry and the end solution definitely cheats in some areas but it works.
Well, that’s pretty much everything involving the Dynamic Pixel Mapping branch of this project. Next, I’ll get into how I made the Character Creator.