Physics-based Animation System for Characters

Currently im working on a PB animation system and I made some progress but…Its hard and there isnt anything much on the internet.
Basically I setup the ragdoll and then apply a constant force on the head or hips to thurst upwards,to keep the ragdoll straight.
Now comes the hard part : walking.
I’ve managed to create a semi-working walking cycle by doing 2 functions attached to each leg with thursters and them using them with coroutines.The first problem is that i cant find a way to make a perfect interval based loop so that each leg waits for the other to move and then to move.
The second problem is that i cant actually figure out a way to make him look like he is properly stepping.
Any info on this dark magic subject would be a blessing guys!
Thank you and have a good day!

1 Like

when doing things based on physics, it’s best to think how it works in physics. real people are supported by their feet, not a floating head. I’m no expert coder, but supporting the character from the bottom up, starting with the feet, seems like the way to go. I would try this:

  • feet stay always against the ground if both: the foot is close enough to the ground and the ankle is bent less than 45 degrees (average flexibility). (you can make the ball of the foot count as grounded too, and after the ankle can bend no more, bend the ball of the foot 45 degrees to allow for crouching)
  • Hips carry the center of mass, and must remain above the heels, or leaning off balance in the direction of movement. Remember, running and walking are not pushing with our feet, they are falling, then catching and pushing ourselves back up with each step
  • The upper body angles forward with the hips, arm motion opposing leg motion for balance. this requires good foot friction to work
  • Knees apply a force from the ankles toward the hips by straightening the two halves of the legs. this is a soft constraint and like a hinge spring when tensed. also notice that if previously moving forward, because the motion is toward the hip, the legs push the hip a a little forward, as well as up.
  • in order to move, the hips bend the torso forward. to strafe, one knee relaxes a bit, letting the other push off, and the relaxed leg catches the fall. All movement is falling, with the feet moving to catch it.
  • if a foot is not able to reach the ground from an ankle, it is not supported, the knee tenses some, and the leg moves in the direction the hips are leaning off balance.the leg extends, and the foot nears the ground to make a grounded connection.

to get the walking gait down correctly, note leaning is only the beginning of walking, the rest is just putting a foot ahead, and allowing the lateral motion to continue.

Thanks for the extensive response!
Im pretty much a newbie with c# so these things will take quite some time to implement.
I know this is a pretty serious topic , but the effect Im trying to achieve is rather comical,like gangbeasts,octodad
and so on.Thanks again!

1 Like

ah, okay, I know gang beasts has the head held up to just under the standing height, with a soft constraint so the foot animation would lift it up. there’s definitely some interesting stuff under the hood there that I can’t quite figure out.

The problem with this is you would likely not want physics but IK, because physically doing this is going to fall apart due to a lack of iterations, or be really quite slow to calculate.

ah, I hadn’t considered that, but that really does seem like the way to go. My only venture into the area was considering the plausibility of a cheap peripheral to apply resistance to the player’s joints from resistances in-game, so I kinda glossed over procedural movement =3=

I think I’m doing exactly what you’re after in my game GORN. Don’t overcomplicate it. Keep the character upright by applying an upwards force on the chest. Keep the chest straightened by using two addforceatposition - an upwards one at the top, and a downwards one at the bottom. Think of the character as a puppet on strings, each force that you are applying is another string - so to straighten something you attach a string to the top and at the bottom and you pull on both of them equally.

A walk cycle is a simple up, then forward, then down force applied to each foot, step by step. You can just apply a forward force to the chest if the foot forces aren’t propagating him forward enough. A more advanced and stable way is to have a position relative to the chest/ground that each foot is following. Apply a downward force to the static foot so it stays on the ground.

There’s no shortcut to doing this, it takes a lot of tweaking. I later wound up adding rotational forces to the knee and hip at the start of a step to make the lift portion look more natural.

Demo of a walk cycle done in this way:

I’m also changing the desired height of the chest over the course of a step for a more natural up/down feel. the lines coming out the feet show (some) of the forces being applied.

5 Likes

i’m working on something like this as well.

https://gfycat.com/SandyEdibleBoaconstrictor

basically it all boils down to how far you want to take the simulation regarding how the characters move and balance. something like sumo tori with simulated weight transfer and attempted self balancing with no rotation locking, or something like exanima which has an IK hybrid system. right now i’m trying to find a nice middle ground between sumo tori and exanima.

2 Likes

damn that looks seriously awesome!

1 Like

Ill pay a $1000 if anyone ever comes up with a Euphoria-like asset.

2 Likes

Thank you for the extensive response and for the useful advices! I think ive seen you on some youtube series on an island! Great work!

Probably overkill for what you want but might be bits a pieces you can borrow:
http://www.goatstream.com/research/papers/SA2013/

Also this google video search has lots on the topic.
https://www.google.com/search?q=Michiel+van+de+Panne+research&rlz=1C1CHBF_enUS718US718&oq=Michiel+van+de+Panne+research&aqs=chrome..69i57.2023j0j4&sourceid=chrome&ie=UTF-8#q=Michiel+van+de+Panne+research&tbm=vid

-Jeff

I’m looking into this as well, but being a newbie I either need to purchase an asset or get a lot of hand holding.

So far, this is the most detailed explanation I’ve found:

EDIT: Oh, this seems very close… very, very close:

gangbeast uses a ball and prismatic joint when walking, it apply force downward on the ball, so the ball will have full friction against floor, then just do rotation for the ball depend on your input axis. When not walking, ball goes back to the “core body part” and collision is ignored against all body parts, both leg will then stand on the floor straight with a tightening effect to keep the body straight. alot of these described above will have to be simplified if you want to run on server simulation with client prediction.(Collision can happen for all other body parts, just make sure you ignore against “BALL”), I did this for following game: 搏基俱乐部 (Punchy Club) - 安卓官方预约 - TapTap

3 Likes

Collision with all body parts is something I personally definitely need.

Found another tutorial:

(Yes, spanish, but worth it, I think… and he’s got a whole series of these if you check his channel.)

I wonder about another thing… would it be possible too use a dynamic mesh collider to achive full body physics?
And how would you add the data from a static mesh collider to a dynamic one…
Thinking of using skeletion too restrict body movment…

Hopfully if that works, use AI too figure out how too do the animation sequence and then have that replace the animation…
AI in mind (TensorFlow).

So too summarize,
Idea: Use dynamic mesh collider too create the physics then use ai too learn the movement from an animation (or many) and then figure out animations on its own after a bit (or very much) training of the AI.

Hope someone might have an idea on how too achieve the dynamic mesh collider and maybe the skeleton (body part) movement restriction.

I haven’t had time to read all the comments, but I agree with this.
As far as I know all game do this instead of trying to simulate actual muscles.

You should think about it more like puppeteering the character.

Hey Devs,

I made a written tutorial covering how to target rotations with configurable joints.

Here’s what you can do with it!

CCDIK Solver + what DinozSayRAWR said.

Or use PuppetMaster (on Asset store). You will be blown away by the possibilities.

You’re welcome :wink: