Treat multiple bodies as group. Weld joint or other approach

Hi,

I'm working on my platformer game and I have started to re-work my player's hitbox. He currently has one box.

I want to re-work this with multiple hitboxes for different parts of the player. I want a box with high friction to simulate his feet and another box with no friction to be the actual body.

Such as:
+----------+ Main collision box with no friction (to prevent the player from getting stuck to walls)
|..........|
|..........|
+----------+ Feet hitbox with high friction.
|..........|
+----------+

My question is how do I treat these two bodies as the same when I want to apply forces etc? What I find about groups in the manual seems to apply for collision filtering only.

I tried welding one body to the other with a weld joint, but they don't seem to stick together the way I want during game play. The high friction box gets lagged behind and it's has a "bouncy" effect to the welding. If this is the way to go, where should the anchor best be placed?

Thanks
I'm guessing that these bodies will never move away from eachother?

In that case, you can simply give a body more than one fixture.
Code:

b2BodyDef bdef
;
bdef.type = b2_dynamicBody;
bdef.position.Set( x,y );

b2Body* body = world->CreateBody( &bdef );

b2FixtureDef fdef1, fdef2;
b2PolygonShape shape1, shape2;

// low friction top box
shape1.SetAsBox( 1.0f, 1.0f, b2Vec2( 0,1 ), 0 );
fdef1.shape = &shape1;
fdef1.friction = 0.2f;
fdef1.density = 0.1f;

// high friction floor box
shape2.SetAsBox( 1.0f, 0.2f, b2Vec2( 0, -0.2f ), 0 );
fdef2.shape = &shape2;
fdef2.friction = 1.0f;
fdef2.density = 0.5f;

body->CreateFixture( &fdef1 );
body->CreateFixture( &fdef2 );
 
Ah, I knew there had to be a better approach to this! Thanks a lot, I will use this in my game 🙂
thanks you very much, i lost two day to found it 🙁 😢
but how to set position to my fixture, it's in first body 🙁
This doesn't appear to work on 2.1a for Flash.

The moment I add a second fixture to a body, the script loads an empty screen with a single circle shape. I delete the the line and the game load normally.

circ = new b2CircleShape( 12.5 / PIXELS_TO_METRE );
fixtureDef.shape = circ;
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.3;
bd.position.Set(startX / PIXELS_TO_METRE, startY / PIXELS_TO_METRE);
var head:b2Body = _world.CreateBody(bd);
head.CreateFixture(fixtureDef);
head.CreateFixture(playerDef);

Original thread: https://box2d.org/forum/viewtopic.php?t=6679