Box2D碰撞检测问题?
我正在使用一个非常简单的 b2ContactListener。然而,当我的对象发生碰撞时,一次物理碰撞会有多个回调。有没有办法修改它或添加一些检查,以便物理上的一次碰撞只有一个回调?我已经为此苦苦挣扎了几个星期,但我似乎无法弄清楚:(
任何人都可以提供任何提示或建议吗?
谢谢!
I am using a very simple b2ContactListener. However when my objects collide, there are multiple callbacks for one collision physically. Is there any way to modify this or add some checks so that there will be only one callbacks for one collision physically? I have been struggling with this for weeks and I just can't seem to figure this out :(
Can anyone offer any tips or suggestions?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,我在对象上使用了布尔标志。
当联系人被解雇时:
如果已设置标志=忽略
否则设置标志并将对象添加到 doSomethingNowWithThis 列表中。
这样,只有一个联系人设置标志,其余的都将被忽略。防止我过度去除。
可能有更好的方法,但这对我有用。
在 iOS 中使用 levelhelper 的示例。
I use a bool flag on my objects for this.
When a contact is fired:
if the flag is set already = just ignore
else set the flag and add the object to the doSomethingNowWithThis list.
This way only one contact sets the flag, and the rest are ignored. Prevents me from over-removing.
There might be a better way, but this works for me.
Example using levelhelper in iOS.