ContactFilter typedef

ContactFilter = bool Function(Collider other, Vector3 normal)

Whether a contact counts, asked of the collider and the way it faces.

The mechanism behind a one-way platform, a phase state, a floor that only some bodies fall through — and the engine knows none of those words. It takes the normal, which is what separates this from Layers: a mask can only skip a whole collider, and a platform you may pass upwards through but must stand on is one collider whose top face counts and whose other five do not.

normal points from the surface towards the body, is axis-aligned like every normal here, and is scratch: read it, do not keep it.

Called from inside the sweep loop, which is the hottest loop in a game, so the argument is a function rather than an object with a method and the null case costs one comparison.

Implementation

typedef ContactFilter = bool Function(Collider other, Vector3 normal);