Dynamic character animation - Using the physics engine or not

Posted by Lex Webb on Game Development See other posts from Game Development or by Lex Webb
Published on 2014-05-28T15:48:24Z Indexed on 2014/05/28 16:01 UTC
Read the original article Hit count: 318

I'm planning on building a dynamic reactant animation engine for the characters in my 2D Game. I have already built templates for a skeleton based animation system using key frames and interpolation to specify a limbs position at any given moment in time.

I am using Farseer physics (an extension of Box2D) in Monogame/XNA in C#

My real question lies in how i go about tying this character animation into the physics engine.

I have two options:

  • Moving limbs using physics engine - applying a interpolated force to each limb (dynamic body) in order to attempt to get it to its position as donated by the skeleton animation.
  • Moving limbs by simply changing the position of a fixed body - Updating the new position of each limb manually, attempting to take into account physics collisions. Then stepping the physics after the animation to allow for environment interaction.

Each of these methods have their distinct advantages and disadvantages.

Physics based movement

Advantages:

  • Possibly more natural/realistic movement
  • Better interaction with game objects as force applying to objects colliding with characters would be calculated for me.
  • No need to convert to dynamic bodies when reacting to projectiles/death/fighting.

Disadvantages:

  • Possible difficulty in calculating correct amount of force to move a limb a certain distance at a constant rate.
  • Underlying character balance system would need to be created that would need to be robust enough to prevent characters falling over at the touch of a feather.
  • Added code complexity and processing time for the above.

Static Object movement

Advantages:

  • Easy to interpolate movement of limbs between game steps
  • Moving limbs is as simple as applying a rotation to the skeleton bone.
  • Greater control over limbs, wont need to worry about characters falling over as all animation would be pre-defined.

Disadvantages:

  • Possible unnatural movement (Depends entirely on my animation skills!)

  • Bad physics collision reactions with physics engine (Dynamic bodies simply slide out of the way of static objects)

  • Need to calculate collisions with physics objects and my limbs myself and apply directional forces to them.

  • Hard to account for slopes/stairs/non standard planes when animating walking/running animations.

  • Need to convert objects to dynamic when reacting to projectile/fighting/death physics objects.

The Question!

As you can see, i have thought about this extensively, i have also had Google into physics based animation and have found mostly dissertation papers! Which is filling me with sense that it may a lot more advanced than my mathematics skills.

My question is mostly subjective based on my findings above/any experience you may have:

Which of the above methods should i use when creating my game?

I am willing to spend the time to get a physics solution working if you think it would be possible. In the end i want to provide the most satisfying experience for the gamer, as well as a robust and dynamic system i can use to animate pretty much anything i need.

© Game Development or respective owner

Related posts about c#

Related posts about 2d