box2d circular body stuck in corners

*爱你&永不变心* 提交于 2019-12-11 08:26:04

问题


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);


来源:https://stackoverflow.com/questions/9451746/box2d-circular-body-stuck-in-corners

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!