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 ActiveCollisionTypes:

/* Set the active collision types when the collider is created. */
let collider = ColliderBuilder::ball(0.5)
.active_collision_types(
ActiveCollisionTypes::default() | ActiveCollisionTypes::KINEMATIC_FIXED,
)
.build();
/* Set the active collision types after the collider creation. */
let collider = collider_set.get_mut(collider_handle).unwrap();
collider.set_active_collision_types(
ActiveCollisionTypes::default() | ActiveCollisionTypes::KINEMATIC_FIXED,
);
assert!(collider
.active_collision_types()
.contains(ActiveCollisionTypes::DYNAMIC_KINEMATIC));
assert!(collider
.active_collision_types()
.contains(ActiveCollisionTypes::KINEMATIC_FIXED));
info

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

ActiveCollisionTypes::default() | ActiveCollisionTypes::KINEMATIC_FIXED