Best way to move a human character?

Topics: Developer Forum, User Forum
Jun 16, 2010 at 7:19 PM

Moving a vehicule is usually simple, since you can often create a simple polygonal version of it and apply movement at the right place, like torque to the wheels. However, moving a human, or any animal, is very different. The legs pushes the body forward, which would make it very complex to replicate in a physic engine.

I use a rectangle to represent the character and the first thing I tried was to apply a force to it. Even with 0 friction, the acceleration was way too low. Humans can accelerate very quickly, but have a low top speed, so I tried to limit to top speed of the character, but this is problematic when the character falls or gets hit by something like a truck, since its speed would still be dependent on the top speed unless I use a complex state machine. I tried to give it a small impulse at first then a constant force, but then if the character slows down and reaccelerate, it will accelerate slower than if it would stop and restart, which makes no sense. Affecting its speed directly generally works, but if the character is walking on a steep angle, it will walk down as fast as it will walk up, which also makes no time. The best method I found was to give it a force reversely proportional with its current speed. It works so far, but it's more of an hack than a proper method to me.

So what would be the best method to get a human (player or AI) to move around realistically?

Jun 17, 2010 at 2:34 AM

I think the best way to move a character is the box+circle technique. See here: http://boxycraft.wordpress.com/2009/06/30/behind-boxboy/ and here: http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=204878 and here: http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=51544


Jun 17, 2010 at 12:38 PM
Alright, I understand the concept. I'm not familiar with angular joints, but the docs on it looks good enough, I'll be fine. I'll probably have a lot of prototypes to do, since I have many very different kinds of character. I have a robot who would probably be better with two wheels and a bug-like character who can walk on walls and ceilings who will probably need a wheel on the front to climb 90 degrees walls. With wheels, I'm wondering how I'll go down a 270 degrees wall, since the character wheels will probably slide down the angle rather than tilting like a box would do. I guess the best option for that would be to have invisible boxes in all corners that will trigger a scripted climb down.