Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit8d45df8664

README.md

ecs.CollisionGroups

Component spec for ecs.CollisionGroups, which maps to the native CollisionGroups — the bitmask membership/filter that decides which colliders interact. Two colliders collide only when (a.membership & b.filter) and (b.membership & a.filter) are both set. The constructor ecs.CollisionGroups{...} builds a value the generic ecs verbs apply, and the component is behavior-bearing: ecs.get exposes per-collider group methods.

Fields

  • membership: number? — the groups this collider belongs to.
  • filter: number? — the groups this collider tests against.

Handle methods

ecs.get(id, ecs.CollisionGroups) returns the generic data handle plus these methods, each bound to the entity's id.

  • apply(membership, filter): store the membership/filter masks on this component and push them onto this entity's colliders. The engine holds the colliders of the entity's rigid body, its standalone collider and the shape it composes onto an ancestor's body to the stored masks as the body is built and before every physics step, so a body built or rebuilt later takes them too. A shape a child entity with a CollisionGroups of its own composes onto the body keeps the child's masks.
  • ignore(otherEntityId, ignore?): set pairwise collision ignore against another entity (ignore defaults to true).

Usage

ecs.insert(id, ecs.CollisionGroups{ membership = 0x1, filter = 0x2 })
local groups = ecs.get(id, ecs.CollisionGroups)
groups:ignore(otherId)