Physics · function

pairKey

The key a pair of bodies is stored under, in either order.

Explained in Your first game, Rigid bodies.

function pairKey(a: number, b: number): number
import { pairKey } from '@driftengine/physics';

Parameters

ParameterTypeDescription
anumber
bnumber

In depth

Two bodies that must never collide cannot always be said with layers. The mask is a property of each body on its own, so it can express "this kind does not meet that kind" and cannot express "these two in particular" — and a ragdoll is entirely the second thing: every bone overlaps the one it hangs from, because that is what having a radius means, while the same two kinds of bone elsewhere in the body must still collide. A consumer that tried it with layers spent a bit per bone and most of the 32 on one doll.