Post feature RSS Populating Mars Part 1

This week I’ve worked on something I was looking forward to for quite some time: NPCs. So far they all looked very alike and only stood around, two things I’ve changed now.

Posted by on

This week I’ve worked on something I was looking forward to for quite some time: NPCs. So far they all looked very alike and only stood around, two things I’ve changed now.

How to turn 4 Clones into a Crowd

Until yesterday I had only four (male) NPCs standing around. As I split every NPC into a head, a body and legs, I was able to get some variety with those parts, but not nearly enough. So in order to increase the variety without making any actual new parts, I implemented a shader (by the great xot) that can take a color and replace it with another (with some cool features like taking similar colors also into account and retaining their shade).

To make this process as easy as possible, I colored the existing parts with a set amount of colors (1 color for skin, 1 for hair, 2 for clothes, etc.). So now I can add as many new heads and bodies and legs as I want and as long as I stick to these colors, they will be properly handled by the shader. The only thing I have yet to figure out is the output colors.

The easiest way is to just randomly assign colors. While this gives a maximum of variety, it doesn’t work for things like skin or hair. For those I defined a range of colors that are randomized.

The range of colors used for the skin of NPCs.

Below is a little gathering of NPCs as they appear in the game. Now there are two issues I still need to address. The first is to make sure that the chosen colors actually are different enough from one another so that they don’t look like a flat, single-colored surface. The second is that in the gif below there are STILL a lot of NPCs that look very alike and even have the same colors. I’m not entirely sure if the shader fails me sometimes or if the randomized colors just have a faible for green and blue (I assume it’s the former).

The typical morning roll call. Spot the clones!

Getting them to Move

As the game will be playing in a colony on Mars, there will be a huge number of NPCs in the streets and buildings. It won’t be like in most rpgs where there’s only like 10 inhabitants of a city that you can talk to, but instead there will be many NPCs going on with their daily lives. They go to work, have a drink, dance in the club, etc.

Look, an unrealistic amount of running around in a police station.

The way I do it right now is by simply assigning paths to some NPCs. This will most likely change in the future, as this leads to a scene that is maybe busy, but not very interesting. I assume very few people would be fooled by this into thinking that this is a lively place they are walking through. It’s just motion without a cause. To mitigate that a little I make them stop for a moment whenever they do a turn that is greater than 90°, but it only helps to break the monotony a little. This will definitely need some more ideas and experimenting.

Here you can see the paths the NPCs follow.

Reacting to the Player

One thing that has been in the game for a few weeks but didn’t actually work that well until now is that NPCs can track an object with their head. In this case, they will follow the player by turning their head. Before, they would simply turn their head until they directly look at the player, but as they are not supposed to be robots, I added some thresholds to prevent an impression from a scene of The Exorcist.

I also check whether they would actually be able to see the player in the first place so that they don’t track your movement all the time.

The white line shows the body direction, the green one the head angle.

This concludes this article about NPCs. I called it “part 1” as there’s still a lot to be done and this is more like a first pass. Next week I will hopefully start with the first interactions between the player and NPCs (mostly interface stuff). I’ll probably share the results in a week, so please be excited.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.