Box2D Forums

It is currently Sat May 18, 2013 2:09 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jan 18, 2012 5:11 pm 
Offline

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:
Image

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
 Profile  
 
PostPosted: Wed Jan 18, 2012 8:52 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
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 :)
http://www.youtube.com/watch?v=0awh5MFJwQo#t=4m26s
http://www.youtube.com/watch?v=FmlMC-JYR1Y
http://www.youtube.com/watch?v=_hsLFV3kwvs#t=1m12s

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


Top
 Profile  
 
PostPosted: Wed Jan 18, 2012 9:25 pm 
Offline

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
 Profile  
 
PostPosted: Thu Jan 19, 2012 11:40 am 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
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
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group