
I am still working on a blue-orangish small city, surrounded by walls and mountins. Only one big street is passing through. One the one side there are several shops and people shopping. On the other side there is the traffic department and an inventor house.
The player has to cross the street to get through the busy city shopping area to the exit to the next area. BUT : The city shopping people have a virus and are spreading it. They do not wear masks. So the player has to find a way to cross the street, avoid being infected and find the exit.
Navigation of the shopping NPCS
I had several things to do here : First, a simple NPC AI System, which lets the shopping NPC spawn at several points like the shop doors or the subway entrances. Then they need to move to one another of these points.
I solved that with the build in Navigation System of Unity3D.
Pooling the shopping NPCs with kPooling
But the spawing of a lot of NPCs could not be done without a pooling system. Instanciating them every time would have slowed down it too much. I found this open source pooling system, kPooling, and it is really amazing. (thanks a lot to Kink3D, a former employe of Unity3D for that).
So everytime a NPC reaches a destionation, I give the NPC gameobject back to the pool and take one if one needs to spawn from it.
The Virus
There are two things with the virus : A Shopping NPC can be infected in various grades. But how to visuale this to the player ? I choose to make a graph shader, that uses a red gradient color to indicate how much the infection has progressed in an infected shopping NPC. Why is this important ? First, the player can aquire argumented reality glasses ingame, that show him this. And : the more a NPC is infected, the greater is the area in which peole get infected in front of him when he coughs.
Writing this shader was a bit tricky, I will publish it here for free use later, also I have to ask in the Unity Forums if there is a better way to do it, but for now I am happy that I found a way to actually do a shader that provides the needed functionality.
More in Part 2 soon.