I spent all the week designing the foundation of NPC animations. I designed walk cycle animations, tried them in Blend trees, tried some of my own custom logic for animation state transitions; but it's all still WIP. I made couple of big technical decisions on implementation of NPCs (more after the image). Here's a basic walk cycle for one of the NPC lumberjacks, it's still WIP.
* In order to implement the NPC characters, I had to design each of them as a state machine, where each state corresponds to the action that enemy is doing (walking, attacking, dying, wood-chopping, etc.). In previous iteration I implemented a state machine architecture of my own. I knew that each state roughly corresponds to a distinct animation and Unity's animator itself is a state machine. However I didn't realize that I could use the
Animator State Machine itself for my purposes. This week when I figured out how to override StateMachineBehaviour class, I decided to forgo my own implementation over Unity's animator. I haven't still figured if everything will work that way, but we will see.
* There are going to be many NPC characters and designing each of them separately would not be feasible. Thankfully there's a feature in Unity's experimental 2d animation package that can solve this problem. As I've talked before, all characters in this games are designed as collections of separate sprites (a sprite for each limb - head, hand, etc.). The animation is achieved by moving these sprites relative to each other. This is different from keyframe approach in 2d games, where entire character is drawn in a single sprite and each frame of animation is a different sprite. Unity's Sprite Library asset gives a handy way to organize different sprites for each limb. Here are some screenshots.
So I can mix-n-match these limbs to create variety of different characters using the same rig. Here are two examples - Ivan and Jack
It also means that I can design all my animations on the same rig and apply them to different characters as well. This will be a big time saver IMO.
You can learn about this technique from this excellent video
* I realized that the visual details of the NPC characters are not visible from the normal zoom level in a typical gameplay. On the other hand their animations are registered and they bring a distinct character to each NPC. So I'm going to spend more time designing these animations and will stick to the blocky sprites that you see now.
* A word about
Astar Pathfinding package. It's awesome. I've implemented my own path finding solutions in last 3 years and wasn't aware of Astar's existence. I learnt about it from
. I'm using the free version of it for now and it has all the features I need. In my past implementations of path finding, I had spent so much efforts on path smoothing. Yesterday I was about to start doing again until I found a Path modifier built inside Astar that does that with a click of a button!
* My design document is getting bigger and more detailed. I've also started to track my task progress in a hierarchical list in a Word document, instead of Trello. For a single person project, I think that's a better approach.
That's pretty much it for this week. Next week I hope to make progress on Animations so that I've 2-3 distinct walking styles. Also will start putting together things as per the script for Chapter 1.
Have a good weekend all!