Implementing animations

Fourth blog. I might even be excited if I had something interesting to write about. Unfortunately I don’t. I’ve been implementing the animations lately, and adding sound effects as well. But there really isn’t anything to say about the sound effects so I’m forced to recount my numerous failures in implementing animations, “sigh”….oh well, let’s get to it.

What?

An animation is essentially just a moving picture. In fact in 2D that’s all it is really. It’s how these pictures are manipulated in order to make them move that’s the tricky part. I mean if a character is moving you don’t want the entire picture of said character to move, then he’ll just slide along the ground. So what you do is you cut the picture into pieces, with each limb being a different piece. From what I understand the program that our artists use, Anima2D, uses “bones” that are attached to these pieces in order to move them in a realistic manner. This however was not my task. My task was a rather simple one; to make the animations play at the right times. Now I say simple only because it SHOULD have been simple. Not for me though, nononono I managed to make it real hard.

How?

As I was saying earlier the process is actually rather simple, we’ll start with the animation controller.animationcontroller
RiflemanShoot, RiflemanIdle, RiflemanWalkCycle and RiflemanDeath are all animations. The gray arrows you see between them are so called transitions, and they do exactly what you’d think they do; they change what animation is to be played. The Shoot, Walk and Death you see in the upper left corner are called parameters and you use those in code in order to make a transition. The Death parameter for instance is a bool, meaning it can only be true or false. In other words when I change that parameter from false to true, the RiflemanDeath animation will play. It will also never change back to another animation 1) because there are no transitions going FROM RiflemanDeath to the other animations, and 2) because the Death bool will never be set to false again, instead the Rifleman will be destroyed. Shoot and Walk are both triggers, which means you can trigger them at any point in your code (like so: animator.SetTrigger(“Move”);) and they will play at that point. To be honest I should probably change the Move parameter to a bool, but it works as it is.

Simple right? Well I had no idea about any of this when I started. I watched a tutorial explaining most of it, but since I had no idea how the animations were actually created or how to troubleshoot them if they didn’t work, it took a LOT longer than it should have. At the moment we only have three animated characters, one of which has 4 animations and the other two only have 3. Getting them all in and working correctly took me a full week. Weekend included. Any programmer reading this will know; that aint right.

Why?

I seem to have already explained this briefly in the What? section again, but in short; Animations adds feeling to a movement. Sure you can move a static picture around as much as you want, but it’s so much more satisfying to see a character behave more like a living thing rather than a statue. Animations help us create that feeling of life in our creations.

 

So that’s me done for this week. Working together with the artists got me through all the hiccups I encountered, I just wish I had known more about animations before taking this task.BUT, it’s done now and I can move on. To something that’ll probably be even more difficult; particle effects. See you next week!

Leave a comment