box2d circular body stuck in corners

2019-08-02 05:46发布

问题:

Good day, I have a circular body which rolls in a certain direction. Some platforms in my game are built perpendicular to each other forming a 90 degrees corner like _| (without the gap :)) My problem is that the circular body gets stuck between the two platforms if it collides with the corner. Only by implying an impulse the body is released but gravity does not seem to affect it anymore.

I have seen posts with solutions but they were all referring to square character bodies.

Has anyone here have a suggestion about this issue ?

Thanks

回答1:

I think the problem may be that the circular body has come to rest and has therefore gone 'to sleep'. Check out the Sleep Parameters section of http://www.box2d.org/manual.html and try the following when you create your bodyDef:

bodyDef.allowSleep = false;

Alternatively you can use some external event to wake up your sleeping body:

myBody->setAwake(true);


标签: iphone ios box2d