Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能使一个身体有时不会与其他身体发生碰撞?我有这个物体,我希望它与所有物体发生碰撞,除非我指定它应该与没有物体发生碰撞。我怎样才能做到这一点?
碰撞过滤是一种可行的方法,尤其是出于您的目的,因为您可以在运行时为某些固定装置设置过滤器,以便随时启用或禁用碰撞检测。
您可以将 isSenor() 设置为 true
bodyDef.isSensor = true;
“当您想知道物体何时会发生碰撞而不触发碰撞响应时,请将 isSensor() 设置为 true。”