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.
collider = (
rp.Collider.ball(0.5)
.active_collision_types(
rp.ActiveCollisionTypes.default_types() | rp.ActiveCollisionTypes.KINEMATIC_FIXED
)
.build()
)
# Set the active collision types after the collider creation.
collider = world.colliders[collider_handle]
collider.active_collision_types = (
rp.ActiveCollisionTypes.default_types() | rp.ActiveCollisionTypes.KINEMATIC_FIXED
)
assert collider.active_collision_types.contains(rp.ActiveCollisionTypes.DYNAMIC_KINEMATIC)
assert collider.active_collision_types.contains(rp.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:
rp.ActiveCollisionTypes.default_types() | rp.ActiveCollisionTypes.KINEMATIC_FIXED