Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

IContactFilterCallback

interface in UnityEngine.LowLevelPhysics2D

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

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.

Public Methods

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. Do not perform any write-operations during this callback for any PhysicsWorld, PhysicsBody, PhysicsShape or PhysicsJoint. A write operation would include setting any property or creating objects. Any attempt to perform a write operation may result in a crash, deadlock or hard to detect corruption. In most cases, performing a read operation is safe and should be limited to simple state read operations such as reading velocities etc.