Starting with Game Character Animation
Over the last few years, I focused on creating high-end game graphics and effects instead of focusing on the game mechanics and creating a fun playable game. What's the point of having good graphics if the game isn't fun to play? So I am taking a step back and selecting which type of games I am going to develop first.
I enjoy playing action and adventure games as well as fighting games (with human characters), so those types of games will be my primary focus. This helps me determine the assets, tools and libraries I need to get started.
Getting Started
Action-Based games with human characters - I'll begin with character animation first.I needed:
- Biped Rigged Character (with proportions I will use with the final characters)
- Simple Lighted Environment with a Grid Floor (helps me check for foot sliding)
- Test Animations (to test animation blending and skin weights)
I had a proxy character I used in the past, for previewing animation in Autodesk's Maya, so I modified and rigged it for games. Next I used Synapse Gaming SunBurn Engine to set the character diffuse colors, light the environment and the set the textures for the Grid Floor. Finally, I exported a few animations from Autodesk's MotionBuilder stock mocap for testing...

Animation Library Testing
The first trial run I used SunBurn's SGMotion Library, but I couldn't achieve the different blending techniques I wanted. My goal was to blend and play several animations at once to any part of the body. Animation blending would help reduce the amount of animation that's needed and save time on production. If it is possible with this library, I couldn't get it to work.
Second trial run, I used DigitalRune Animation library, although the library is still in alpha, I succeeded with the Animation Blending tests. The integrating with SunBurn and DigitalRune Animation was smooth as silk. Only setback was it takes so much code to animate and blend characters, plus the animation pipeline from the examples - merged and created huge files.
Streamline the Workflow
First I needed a few classes to help streamline the process of applying and using animations. I created a basic Actor Class to manage all skinned models, an Animation Class to control animations and a Motions Class to manage a collection of animations. These classes will easily allow me share animations between characters as well as apply, blend and transition animations.example 1:
Actor Bill = new Actor();
Motions RunMotions = new Motions("RunCollection");
Bill.Animation = RunMotions["RunFast"];
Later, I found it more convenient to create separate Animation classes derived from the Motions Class that eliminated the use of strings to request an animation and allow faster access with less garbage collection.
example 2 (better):
Actor Bill = new Actor(); RunMotions run = new RunMotions(); WalkMotions walk = new WalkMotions(); Bill.Animate.Play(run.fast); Bill.Animate.CrossFade(walk.fromRun, 0.5f); //float controls fade transitions
Optimize the Content Pipeline
Finally, I decided to create an animation processor content pipeline that returns a Dictionary containing the Skeleton and SkeletonKeyFrameAnimation since that's essentially all DigitalRune library needs for character animation. My approach was quite simple. I used a text file to list all of the animation folders to search for in the Game's Content Project Directory, then it created an animation collection based on the folder name and the fbx files inside it. For example the "walk" folder contains default.fbx, fast.fbx, slow.fbx., etc., will tell the processor create a new file named walk, and returns all animations found in the walk folder. Then I can load and read the new walk file with my Motions Class mentioned earlier.Simple Method I used to return the fbx files from a directory...
private void LoadAnimsCollection(NodeContent input, ContentProcessorContext context,
string directoryPath, out string animsList)
{
// directory and file info
DirectoryInfo dir;
FileInfo[] files;
//animations
StringBuilder anims = new StringBuilder();
// load fbx files
dir = new DirectoryInfo(directoryPath);
if (dir.Exists)
{
files = dir.GetFiles("*.fbx");
//add all file names
for (int i = 0; i < files.Length; i++)
{
anims.Append(files[i].Name);
if (i < files.Length - 1) anims.Append(';');
}
}
else
{
context.Logger.LogWarning(null, null,
"Animation Directory Not Found:" + directoryPath);
}
//anims list
animsList = anims.ToString();
}
This reduced my file sizes tremendously, basically from 12mb to 400kb. Not only did this reduce build times it also allowed me to easily update and add single and/or multiple animation files much quicker and efficiently.
Here an example of Mocap applied to my Test Character.

What's Next?
Seems like a good start. Since animations can easily be applied to my character, my next objective will be to control the character movement and animation with a character controller.
Subscribe to:
Post Comments (Atom)
Brilliant work every buddy can get lots of inspiring info, keep on posting this category of cheerful articles.
ReplyDeleteweb video production
3d animation
explainer video