Manager, Moreover

Since the critter will evolve through stages in life we would have to create some sort of evolution process. My thoughts around this was to have one game object that could change mesh, material and collider, depending upon which stage its currently in. I started this by giving the critter object (see previous blog post) access to all the different meshes and mesh-colliders within its own script. Then by referring to the age in the critter save it could change its own presence. This sounds quite straightforward, but it turned out it was not. While this way of solving the issue definitely worked, and it worked quite well, a bigger issue rose when the different stages of age gave the critter more and more ways of interaction. The egg for example, can only feel temperature-changes and become more or less dirty. However when the critter is at the baby stage it can feel that and also feel hunger, happiness and so on. This meant that I had to separate the feelings depending on the age of the critter. This would turn out to totally clog my workflow, not because it was hard to make it work, but I felt it was nearly impossible to keep track of all the different emotional changes and states in all the different stages. Moreover it was deeply time consuming to create all the stages of the critter at the same time.

The solution for this was to scrap these plans. To make four different scripts for the different stages of the critters life, and also create four different game objects to store the mesh information. This also made it, if not possible, but easier to handle the transitions between the different stages. I implemented these as an array of four game objects in ”The Manager” script. This stored all of the stages as prefabs, a fifth and separate game object in the script works as the ”current” critter. So to explain this; the critter is currently in its egg stage, so the current game object is the game object on the first position of the array och game objects. When later the egg hatches, the manager sees that the next stage has been initialized and changes the current game object to the second game object of the array. This made it easy to handle the transition between the stages. It also made it easy to just create four different scripts, one for each of the game objects. Which meant that all the information for the critter already was divided between the stages.

About Christoffer Tornstråle

2015 Programming