@ue-too/dynamics / CollisionCategory
Variable: CollisionCategory
constCollisionCategory:object
Defined in: collision-filter.ts:146
Predefined collision categories for common game entities.
Type Declaration
DYNAMIC
readonlyDYNAMIC:2=0x0002
ENEMY
readonlyENEMY:8=0x0008
PICKUP
readonlyPICKUP:64=0x0040
PLATFORM
readonlyPLATFORM:128=0x0080
PLAYER
readonlyPLAYER:4=0x0004
PROJECTILE
readonlyPROJECTILE:16=0x0010
SENSOR
readonlySENSOR:32=0x0020
STATIC
readonlySTATIC:1=0x0001
Remarks
These are bitmask constants (powers of 2) that can be combined using bitwise OR. You can define up to 16 categories using values from 0x0001 to 0x8000.
Example
Using predefined categories
typescript
// Player collides with everything except other players
player.collisionFilter = {
category: CollisionCategory.PLAYER,
mask: ~CollisionCategory.PLAYER & 0xFFFF,
group: 0
};
// Projectile only collides with enemies and static objects
projectile.collisionFilter = {
category: CollisionCategory.PROJECTILE,
mask: CollisionCategory.ENEMY | CollisionCategory.STATIC,
group: 0
};