As I always say I need to get better at writing these things. It always helps when I hear from one of you about the project as it helps me to know there is someone actually wanting to listen to one of my rambles.
This week I’ve managed to make a lot of progress. There is a lot of foundation code that I’m trying to build to ensure that the game can expand in the right directions. A good data pattern and data flow is rather important to ensuring I don’t bottleneck myself. This week I worked a bit on how some of the visuals get tied to some of the data.
As I’m using Unity 5 to create Mercury Fallen I had initially been using the Mecanim system for colonist idle/walk animations. The system worked fine until I wanted to be able to hot swap animations at run time. After doing some research I discovered Animation Override Controllers which allow you to override the current animation states clip. You can manually create a new Animation Override Controller in code which can be used to replace the current running clip. After doing some tests and getting it working I found the whole thing to be rather messy.
This led me to start thinking about the legacy animation system instead. I don’t need a lot of fancy state behaviors, I just need to play an animation for given actions. So I re-wrote the animation system currently using Mecanim and replaced it with the the simpler legacy animation system. There were two main reasons for switching over the legacy system
- The whole system is far cleaner to handle from code which allows for easier switching of animations (at least for my usage).
- Modding is always something I’m keeping track of in the back of my head so I wanted something that was easier to add on to at run time.
The end result of the new system allowed me to tie animation clip names to an action. This way any action could have an animation play while the action was being performed. Right now its focus is for the colonist, but I have some plans to expand the action system in to a more generic state machine type system that would also work for placeable structures as well.
The first test I did of the action/animation system was for construction. I wanted an animation to play while the colonist was performing the construction action, but the colonist also needs to hold an object in their hand while doing it. All visible objects in the game inherit off of a GameEntity class which also acts as a storage container for components. While Unity has its own component system I wrote a custom component management system for my data objects.
Using my custom component system I was easily able to add a basic prefab attachment component which could be used by an action to attach/detach the relevant prefab object. In this case I wanted a blow torch attached to the hand bone while playing the construction animation. It’s still a bit rough around the edges, but I’ll expand on it more later.
There was also a bunch of boring stuff accomplished this week like code clean up and organization as well as getting svn setup for my work files. I will leave you with a new picture showing a little bit more structure that is a lot closer to representing the direction of Mercury Fallen.