Interface ContactFilter


public interface ContactFilter

Decides, step by step, whether two touching bodies in a PhysicsWorld push on each other. Install with PhysicsWorld#setContactFilter(ContactFilter).

Returning false lets the bodies pass through each other for this step only; the question is asked again on the next step while they still overlap. That is how one-way platforms, team pass-through and "ghost" pickups are made -- PhysicsWorld#setOneWay(PhysicsBody, boolean) is the stock one-way rule.

Called from inside PhysicsWorld#step(float). Do not create or destroy bodies here.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    shouldCollide(PhysicsBody a, PhysicsBody b, float normalX, float normalY)
    Whether two bodies collide this step.
  • Method Details

    • shouldCollide

      boolean shouldCollide(PhysicsBody a, PhysicsBody b, float normalX, float normalY)

      Whether two bodies collide this step.

      Parameters
      • a: one body
      • b: the other
      • normalX: the contact normal from a to b, screen space
      • normalY: the contact normal from a to b, screen space (positive is down)
      Returns

      false to let them pass through each other this step