如何检测碰撞,但不会在box2d碰撞? [英] How to detect collision but do not collide in box2d?

查看:183
本文介绍了如何检测碰撞,但不会在box2d碰撞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测身体是否与其他身体碰撞,但不会对此碰撞作出反应。

How to detect if body collides other body but do not react on this collision.

默认 i - 检测碰撞和物体碰撞。

By default i - detect collision and bodies collide.

如果我设置fixtureDef过滤器 - body不会碰撞,但是我不能检测到碰撞。

If i set fixtureDef filter - bodies do not collide but i can not detect collision.

请帮助!

推荐答案

如果灯具不需要碰撞与任何你可以使它成为一个传感器。如果你需要它碰撞一些东西,但不是别人,你可以在冲突侦听器的PreSolve中做联系 - > SetEnabled(false),取决于它碰撞了什么。

If the fixture never needs to collide with anything you could make it a sensor. If you need it to collide with some things but not others you could do contact->SetEnabled(false) in the PreSolve of the collision listener, depending on what it collided with.

这篇关于如何检测碰撞,但不会在box2d碰撞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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