This blog has moved. Visit Groundswell Games for the latest. Remember to update your bookmarks and RSS feeds.

Tuesday, September 4, 2007

Fun with blended animation

In this post I'm going to dig into a particular topic a little bit: animation. First, a little setup.

When I switched to Unity from Torque, I also decided to change the nature of my battle system. I had been working toward a time-based battle system in Torque, which meant that each character or enemy in the battle had a timer that would reset after each move and then refill over a period of time. When the timer filled, that character/enemy would enter its desired move into a queue that would execute one move at a time.

One big advantage of this system is that it's easier to input moves for multiple characters (since only one character/enemy is doing anything at any given time). Unfortunately, it's also a bit dated (think Final Fantasy VII) and works best with a separate battle screen.

So, in Unity I'm working on a more "real-time" system like World of Warcraft or Final Fantasy XII where enemies are visible all the time, have an aggro range, etc. This type of system is much more realistic and helps maintain the illusion of the game world, which is something I want to do as much as possible.

So what about animations?
Time-based systems make animations a little easier to handle, since each animation occurs in sequence and involves the entire skeleton. A basic move might go something like this.

  1. "Idle" animation playing before the move.
  2. Play a "run" animation and move toward the target.
  3. Once the character reaches the target, transition to an action animation (like swinging a sword).
  4. Play a "run back" animation and move back to the starting location.
  5. Transition back to the "idle" animation.
A real-time battle system isn't quite so neat. At any time, your characters can be running in any direction while attacking, being attacked, casting a spell, etc. So your animation setup needs to be pretty flexible. This kind of thing is usually handled through the concept of animation blending. Here's Unity's discussion of the subject. To use blended animations, it's often a good idea to create separate upper and lower body animations that are combined at runtime. So your animation setup might look something like this:
  • Full body
    • Standing
    • Walking
    • Running
    • Strafing
    • Walking/running backwards
  • Upper body only
    • Swinging weapon
    • Spell casting
    • Blocking an attack
    • Taking damage
With a blended animation system, you can give the upper body animations control over the affected joints in the skeleton when necessary, without interrupting whatever is happening in the lower body. This way you swing a weapon while standing, running, or whatever. Also, with a layering system like Unity's you can blend multiple upper body animations at once. This means you can run, swing a weapon, and take damage all at the same time.

Learning to animate
Animation is a very complex subject and an art in itself. I don't claim to be very good at it, but there are a lot of good basic tutorials out there. I'm particularly fond of this one, which explains the process of animating a run cycle.

No comments:

Post a Comment