Box2D Forums

It is currently Wed May 22, 2013 4:25 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Jun 21, 2012 12:57 pm 
Offline

Joined: Tue May 01, 2012 7:17 pm
Posts: 28
Hi,

i don't understand why my character bounces against the ground : when the character touches the ground, the trunk goes a bit down "inside" the legs, and then takes its position a bit above. Would anyone know how to fix it?
I set the "restitution" to 0 for each body part, and i added lowerTranslation/upperTranslation to 0 (otherwise the trunk goes through the legs) :

Code:
/*
     *
     * LEGS
     *
     **/
    legs = [CCSprite spriteWithSpriteFrameName:@"legs.png"];
    legsBody = [self createLegsAtLocation:
                body->GetWorldPoint(b2Vec2(0.0/PTM_RATIO, -70.0/PTM_RATIO))
                               withSprite:legs];
   
    b2Transform axisTransform;
    axisTransform.Set(b2Vec2(0, 0), body->GetAngle());
    b2Vec2 axis = b2Mul(axisTransform.R, b2Vec2(0,1));
   
    b2PrismaticJointDef prisJointDef;
    prisJointDef.Initialize(body, legsBody,
                            legsBody->GetWorldPoint(b2Vec2(0.0/PTM_RATIO, -70.0/PTM_RATIO)), axis);
    prisJointDef.enableLimit = true;
    prisJointDef.lowerTranslation = 0.0/PTM_RATIO;
    prisJointDef.upperTranslation = 0.0/PTM_RATIO;
    world->CreateJoint(&prisJointDef);


I've tried to show this with those images : the first one show the size of the trunk and the legs, and the second one shows that the trunk goes through the legs :

Attachment:
Capture d’écran 2012-06-21 à 22.00.58.png
Capture d’écran 2012-06-21 à 22.00.58.png [ 27.76 KiB | Viewed 284 times ]

Attachment:
Capture d’écran 2012-06-21 à 22.00.34.png
Capture d’écran 2012-06-21 à 22.00.34.png [ 30.52 KiB | Viewed 284 times ]



Also, the legs go through the trunk in this example, is there a way to fix this?
Attachment:
Capture d’écran 2012-06-21 à 21.47.31.png
Capture d’écran 2012-06-21 à 21.47.31.png [ 70.9 KiB | Viewed 285 times ]


Thanks a lot for your help


Top
 Profile  
 
PostPosted: Thu Jun 21, 2012 5:21 pm 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
What are the densities of the legs and the trunk? The trunk might be a little heavy.


Top
 Profile  
 
PostPosted: Thu Jun 21, 2012 7:03 pm 
Offline

Joined: Tue May 01, 2012 7:17 pm
Posts: 28
Thanks, you're right... :D it works fine now.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], Google [Bot] and 6 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