Skip to main content

collider_active_collision_types

By default, collision-detection is completely disabled between two colliders when both are attached to non-dynamic bodies. Sometimes, it can be useful to enable collision-detection between, e.g., a collider attached to a kinematic rigid-body and a collider attached to a fixed rigid-body. This can be done by modifying the collider's active collision types, a bit mask made of the R3_COLLISION_TYPES_* flags:

/* Set the active collision types when the collider is created. */
R2ColliderDesc collider = r2BallColliderDesc(0.5);
collider.activeCollisionTypes = R2_COLLISION_TYPES_DEFAULT | R2_COLLISION_TYPES_KINEMATIC_FIXED;
/* Set the active collision types after the collider creation. */
r2Collider_SetActiveCollisionTypes(collider_handle,
R2_COLLISION_TYPES_DEFAULT | R2_COLLISION_TYPES_KINEMATIC_FIXED);
assert(r2Collider_ActiveCollisionTypes(collider_handle) & R2_COLLISION_TYPES_DYNAMIC_KINEMATIC);
assert(r2Collider_ActiveCollisionTypes(collider_handle) & R2_COLLISION_TYPES_KINEMATIC_FIXED);
info

To enable collision-detection between kinematic bodies and fixed bodies (as well as dynamic bodies), set its active collision types to:

R3_COLLISION_TYPES_DEFAULT | R3_COLLISION_TYPES_KINEMATIC_FIXED