# Box2D Forums

 It is currently Wed May 22, 2013 7:17 pm

 All times are UTC - 8 hours [ DST ]

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Friction on bodies with changing shapesPosted: Wed Jan 18, 2012 5:11 pm

Joined: Mon Sep 19, 2011 9:44 pm
Posts: 2
I'm attempting to make a walking quadruped in a Box2D-based game. My current approach involves a box and eight edges, like this:

This approach seems to have a few problems, though. As I change the endpoint positions on the b2EdgeShapes, the box does move up and down, but there appears to be no friction with the ground when I do this, so the body does not move forward. I tried applying a force to the body when it was walking, but this quickly accelerates it to entirely uncatlike speeds, so I settled on setting the velocity directly. This looks very unnatural, especially when the player presses and releases the movement keys very quickly.

Is there a way to get friction to work in setups like this, or am I approaching this wrong?

Top

 Post subject: Re: Friction on bodies with changing shapesPosted: Wed Jan 18, 2012 8:52 pm

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
There is friction, but if by "change the endpoint positions" you mean setting the edge fixture points directly instead of moving a body, then the problem would be that from the physics engine's point of view they are not actually moving. You would need to put them on bodies of their own and move the body properly to get any response. (Note that bodies with only edge fixtures have no mass so you would need to add a polygon or circle to them as well.)

If you just want it to look like it's walking and apply a force that would be good, I never thought of that You will just have to check the speed and reduce the force as the uhm... cat approaches its maximum allowable speed.

Getting this kind of walking creature working in Box2D is not so easy. Even if you make each leg its own body you will probably still find the low friction to be an issue, and I think you will also need some kind of suspension so that the feet keep better contact with the ground. Check out these videos for some attempts

... actually that last one I would call a success, rather than just an "attempt".

Top

 Post subject: Re: Friction on bodies with changing shapesPosted: Wed Jan 18, 2012 9:25 pm

Joined: Mon Sep 19, 2011 9:44 pm
Posts: 2
Quote:
if by "change the endpoint positions" you mean setting the edge fixture points directly instead of moving a body, then the problem would be that from the physics engine's point of view they are not actually moving.

Yes, that is indeed what I'm doing. I figured it was something like that.

That last video is very similar to what I want to do (and I agree, it's definitely more a success than an attempt). It seems that they're using circles for the feet, but there are no edges connecting them to the body, so I assume that's using the separate-bodies approach you mentioned. What type of joint is that using? It doesn't appear to be a fixed-distance joint; maybe a springy one?

Top

 Post subject: Re: Friction on bodies with changing shapesPosted: Thu Jan 19, 2012 11:40 am

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1517
Location: Tokyo
That's a good question. They are definitely separate bodies, but it looks like they are being moved in a pre-defined curve rather than with joints. My guess is that he is just using them to detect the ground, and then apply some force/impulse to the main body based on what the feet currently have available to stand on.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC - 8 hours [ DST ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: