An interface that when implemented by a UnityEngine.Object, can be called as a target when a PhysicsShape has PhysicsShape.contactFilterCallbacks set to true. The PhysicsWorld the PhysicsShape is in also has to have its PhysicsWorld.contactFilterCallbacks set to true.
Method | Description |
---|---|
OnContactFilter2D | Called when a pair of shapes are determined to be in contact. This is called to decide if a contact will be created for these shapes, allowing contact creation to be bypassed so a contact will not go to the solver. This is only called if the PhysicsWorld has PhysicsWorld.contactFilterCallbacks set to true. An event is only produced if one of the PhysicsShape have PhysicsShape.contactFilterCallbacks set to true. This is called for both triggers and non-triggers but only with Dynamic bodies. This callback occurs during the simulation and must be thread-safe as it can be called from any thread, therefore extreme care must be taken. During this time, the simulation state is undefined so you should not perform any read or write operations during this callback for any PhysicsWorld, PhysicsBody, PhysicsShape or PhysicsJoint. An exception to this is reading UnityEngine.LowLevelPhysics2D.PhysicsUserData from any object which is a completely safe read operation therefore any required information should be encoded there. Any attempt to perform any other read or write operation may result in a crash, deadlock or hard to detect corruption. |