box2d圆形主体卡在角落 [英] box2d circular body stuck in corners

查看:101
本文介绍了box2d圆形主体卡在角落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,我有一个朝特定方向滚动的圆形物体。我游戏中的某些平台相互垂直,形成90度角,例如_ |。 (没有间隙:))
我的问题是,如果圆形物体与拐角碰撞,则它会卡在两个平台之间。仅通过暗示冲动即可释放身体,但重力似乎不再影响它。

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 ?

谢谢

推荐答案

我认为问题可能在于通函身体已经休息,因此已经入睡。查看 http://www.box2d.org/manual.html 的睡眠参数部分,然后创建bodyDef时,请尝试以下操作:

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

这篇关于box2d圆形主体卡在角落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆