1
\$\begingroup\$

What are the standard solutions for animating characters in physics-simulated environments?

Let me explain what I mean - in most games characters are pretty much excluded from physics simulation - there are no forces acting on specific body parts (only gravity for the whole character) and limbs are forced to go into positions specified in key frames of animation... which in turn may produce infinite forces on the limbs and we know real muscles have limited strength...

What I want is character animation based on simulated muscles with plausible limitations - so character walking into a 1 T stone won't move it, or if he gets hit with a fast flying brick he would realistically fall (and brick won't just bounce like from the wall, whit character standing still like nothing happened).

Are there libraries that can do that? Maybe free ones for 2D simulations?

\$\endgroup\$

4 Answers 4

3
\$\begingroup\$

Inverse kinematics. That is the word I think you are looking for (easily googlable). As for libraries, I do not think so. It is very rare technique - the only game I can think of using inverse kinematics is Kingdom Come: Deliverance.

\$\endgroup\$
1
\$\begingroup\$

Mmmm, interesting question.

The first approximation could be the following: simply divide your character into a set of physical bodies. I mean, you could calculate resultant force on legs, feet, arms and hands and operate with the results. Think in Rayman, for example. It can be a good model to start with. The character would be formed by head, body, hands and feet. Every component would be attached to the body with a rope-like object (so if you make a lot of force in the body, the other parts will also be affected and viceversa). For example, if you pull a hand with a external force, the hand will move. But also a elastic force would appear to the hand, proportional to body distance. This will limit the separation. Also a proportional force would appear on body, pulling our character... I think you get the basic idea. Of course, if you add more elements, your model will be more realistic, but it will be also difficult to calculate.

Also, you can be a bit tricky. Looks like you want a character that reacts realistically to extern media. The examples you mentioned could be solved using a "walk force" (the force the body do in another body when it walk into it) proportional to walk speed, so if the player runs it will be able to move the stone. For the falls, simply divide your sprite into regions, get the collision angle and play an addecuate animation. You could have a set of 2-3 animations and make some changes (angle fall or speed) via code to make look it realistic. And believe me: a good animation with an appropiate walk speed can emulate perfectly muscle movement and physical behaviour of your character, if you code it well.

Hope this give you some ideas. It may not be the anwser you were expecting, but I think you first have to plan which simulation method are you going to use in detail :D

\$\endgroup\$
1
\$\begingroup\$

I've been puzzling with this in the creation of my physics based game. I've decided to settle with creating my animations used a skeletal key-frame based animations system (Similar to flash if you've used it).

I will then create physics bodies for each 'limb' of my character. Each of these limbs will have forces applied (depending on the distance from the intended position in the animation) in order to try and move them to the correct position.

This will allow reaction to collisions with scene objects, as well as reaction to projectiles and other effects.

in essence, you will have a fixed animation running in the background, with a physics based character running on top, which will always try its best to match the fixed animation. This should create a reasonable approximation of correct reactions to a physics based environment.

This is just my suggestion however, i did do a bit of research like you are before deciding on this method, but found a distinct lack of information on the subject.

\$\endgroup\$
3
  • \$\begingroup\$ It sounds like a good idea, but did you have any success with your approach? I know for a fact that when physics is involved ideas that sound good on paper can produce unpredictable results... \$\endgroup\$
    – zduny
    Jul 22, 2014 at 10:36
  • \$\begingroup\$ My initial tests have produced reasonable results, but its the sort of thing that will take A LOT of fine tuning. Unfortunately i am not far enough through the implementation to know yet. My best suggestion would be to just give a few methods a try. I've only really seen physics based animations in AAA 3D games, and they don't like revealing their secrets! \$\endgroup\$
    – Lex Webb
    Jul 22, 2014 at 10:40
  • \$\begingroup\$ Yeah it seems like a subject that could use more of an academia level research... \$\endgroup\$
    – zduny
    Jul 22, 2014 at 10:44
1
\$\begingroup\$

There are a few solutions to your query. This field of study is called "Physically Based Character Animation".

You could try incorporating Ragdoll Physics: https://www.youtube.com/watch?v=-9wtaAOzpkc Ragdoll Physics became very popular around the year 2000 with the popular game Hitman. In the past decade, it has been very popular in death animations.

Also, you might want to consider the implementations from Roy Featherstone (1987) and Brian Mirtich: https://people.eecs.berkeley.edu/~jfc/mirtich/thesis/mirtichThesis.pdf This is similar to using Inverse Kinematics and making each limb a rigid body.

Using a sphere as a rigid body around the character is the least computationally expensive approach. Another more expensive approach is to make every element of the character a rigid body. The most computationally expensive (and still in research phases) is simulating the inner muscles of each limb/muscle in the character.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .