Search code examples
libgdxbox2d

Box2d sensors - contact callback in each step


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.


Solution

  • 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.