canCollide

View sourcecanCollide(propA: PhysicsProperties, propB: PhysicsProperties): boolean

Checks whether two bodies should proceed to narrowphase collision testing.

Both bodies must pass the bidirectional collision filter: propA.group must overlap propB.mask, and propB.group must overlap propA.mask. At least one body must have a non-zero inverse mass, and a pair is skipped when both bodies are sleeping.

The helper reads the values from PhysicsProperties but does not change either object or inspect the bodies’ Collider2D shapes. The group and mask fields are expected to be compatible BigInt bit fields.

Examples

import { PhysicsProperties, canCollide } from '@wimaengine/narrowphase'

const dynamic = new PhysicsProperties()
dynamic.invmass = 1
const staticBody = new PhysicsProperties()

canCollide(dynamic, staticBody) // true

Parameters

NameDescriptionDefault
propA

Collision and mass properties for the first body.

—
propB

Collision and mass properties for the second body.

—

Returns

true when the pair passes mass, filter, and sleeping checks.