Box2d传感器 - 每一步都联系回调(Box2d sensors - contact callback in each step)

我已经在ContactListener创建了一个ContactListener和一个传感器夹具,并希望在每一步中都有一个联系回调。 我的问题是beginContact和endContact显然只在联系人开始和结束时被调用,但是只要联系人持续存在就不会被调用。 在这些情况下,建议使用preSolve或postSolve但这些不适用于传感器。

如何在每个步骤中获得与传感器的联系回调? 提前感谢任何建议。

I've created a ContactListener and a sensor fixture in box2d and would like to get a contact callback in each step. My problem is that beginContact and endContact are obviously only called when a contact begins and ends but not as long as the contact persists. In these cases it is recommended to use preSolve or postSolve but these are not implemented for sensors.

How could I get a callback for contacts with a sensor in every step? Thanks in advance for any advice.

最满意答案

我现在的方法是在这种特殊情况下不使用传感器而是常规灯具,并在ContactListener.preSolve调用contact.setEnabled(false)以避免任何物理反应并模拟传感器。

My approach is now to not using sensors but regular fixtures in this particular case and to call contact.setEnabled(false) in ContactListener.preSolve to avoid any physical reaction and simulate a sensor.

Box2d传感器 - 每一步都联系回调(Box2d sensors - contact callback in each step)

我已经在ContactListener创建了一个ContactListener和一个传感器夹具,并希望在每一步中都有一个联系回调。 我的问题是beginContact和endContact显然只在联系人开始和结束时被调用,但是只要联系人持续存在就不会被调用。 在这些情况下,建议使用preSolve或postSolve但这些不适用于传感器。

如何在每个步骤中获得与传感器的联系回调? 提前感谢任何建议。

I've created a ContactListener and a sensor fixture in box2d and would like to get a contact callback in each step. My problem is that beginContact and endContact are obviously only called when a contact begins and ends but not as long as the contact persists. In these cases it is recommended to use preSolve or postSolve but these are not implemented for sensors.

How could I get a callback for contacts with a sensor in every step? Thanks in advance for any advice.

最满意答案

我现在的方法是在这种特殊情况下不使用传感器而是常规灯具,并在ContactListener.preSolve调用contact.setEnabled(false)以避免任何物理反应并模拟传感器。

My approach is now to not using sensors but regular fixtures in this particular case and to call contact.setEnabled(false) in ContactListener.preSolve to avoid any physical reaction and simulate a sensor.