Two devblogs in a week.
Christmas has come early.
Colonists are the little creatures that occupy your station.
They look like this:
This week (and part of last) we separated the colonists into multiple body parts.
The 6 body parts are:
A useful reason to separate body parts is that it allows us to animate them independently.
In the old game, the colonist was composed of 2 sprites: head and body. This made it very time consuming to add new animations, because a unique sprite had to be drawn for every possible animation combination.
For example, if we wanted a colonist to stand and carry a crate we had to draw a separate sprite with straight legs and arms out. If we wanted that colonist to walk and carry we would have to draw another new sprite. This time, with the legs bent and the arms out.
In both cases, the arms were held out, but an entirely new sprite had to be hand drawn.
With the new system, we only have to draw one set of sprites for carrying and we can apply them to any valid combination (sitting, sleeping, walking, standing, kneeling). This saves a lot of time and makes it much easier to create more body types (like a robot or obese colonist).
Here’s an example gif. The arms are carrying. The legs are walking. The head is blinking and the eyes are opening/closing.
We can easily remove body parts from a colonist now too.
In the old system, if we wanted to remove a colonist’s leg, we would have to draw a brand new body (without a leg) and sprites for every single animation combination.
There are a lot of combinations.
2 arms 2 legs, 1 arm 2 legs, 0 arms 2 legs
2 arms 1 leg, 1 arm 1 leg, 0 arms 1 leg
You get the point. It’s a lot of hand drawn sprites. It wouldn’t even be worth it.
With this new system, it’s somewhat painless (get it?) to remove legs.
We can easily replace limbs too.
We could mix and match body parts to create some sort of Frankenstein’s Monster with an alien right leg, human left arm, robotic face, iron-man style right arm, and a cane for a left leg.
We don’t have any sprites for that, but we do have some work-in-progress sprites of a robotic arm:
(Again, I want to stress how much easier this is now)
How It (mostly) Works
If you remember from our earlier post, the entire game is built around Agents, Components, and Events. (Agents are basically GameObjects, but Unity stole that term)
Each body part is a separate Agent, so they can have whatever unique component we want on them.
You could add a component to the robotic arm that increases the strength of a colonist. You could create a demonic arm that requires food (I don’t know why you would). Or you could add a SmellyComponent to a rotting arm.
Each body part also has a unique set of attributes on it.
For example, an arm might have: “arm”, “robot”, “destroyed”, “variant3”. This would describe a robotic arm that has been destroyed (the third variant).
When a colonist is created, they find and attach the correct body part to themselves. At any time, we could internally remove a body part and replace it with something else.
Animating the body parts is internally complexish, but I’ll summarize how it works.
When animating, there are 5 things we can change:
Sprite position (move sprite around)
Sprite (change image)
Base Position (another method of changing the position, independent of sprite position)
Sorting order (used to render sprites in front of or behind other sprites)
IsInverted (we flip the limbs 180 degrees instead of creating brand new sprites for left vs right)
We also have a concept of “AnimationPose”. Examples are “Walk1”, “Walk2”, “Carry”, “Sit”, “Stand” etc.
Combined together, we can make the left arm move up during “Walk1” and then we can move it back down during “Walk2” (while also changing the sprites that the legs are using).
By the way, the colonists also have 4 sides, so for every single “pose” we have to provide data for Forward Left, Forward Right, Back Left, and Back Right.
Body parts are a complex subject. There were a lot of topics that I didn’t discuss.
We’re sticking to our plan of making 1 object do 1000 things instead of 1000 objects that can do 1 thing.
Colonists can now do at least 1 more thing.
Thanks for reading.