Function interactionGroups

  • Calculates an InteractionGroup bitmask for use in the collisionGroups or solverGroups properties of RigidBody or Collider components. The first argument represents a list of groups the entity is in (expressed as numbers from 0 to 15). The second argument is a list of groups that will be filtered against. When it is omitted, all groups are filtered against.

    Example

    A RigidBody that is member of group 0 and will collide with everything from groups 0 and 1:

    <RigidBody collisionGroups={interactionGroups([0], [0, 1])} />
    

    A RigidBody that is member of groups 0 and 1 and will collide with everything else:

    <RigidBody collisionGroups={interactionGroups([0, 1])} />
    

    A RigidBody that is member of groups 0 and 1 and will not collide with anything:

    <RigidBody collisionGroups={interactionGroups([0, 1], [])} />
    

    Please note that Rapier needs interaction filters to evaluate to true between both colliding entities for collision events to trigger.

    Returns

    An InteractionGroup bitmask.

    Parameters

    • memberships: number | number[]

      Groups the collider is a member of. (Values can range from 0 to 15.)

    • Optional filters: number | number[]

      Groups the interaction group should filter against. (Values can range from 0 to 15.)

    Returns number

Generated using TypeDoc