character_controller_filtering
It is possible to let the character controller ignore some obstacles. This is achieved by configuring the
filter argument of the KinematicCharacterController.move_shape method. This QueryFilter class is detailed in the
scene query filters section:
- Its
flags(aQueryFilterFlags, also set by constructors likeQueryFilter.exclude_dynamic()) allow you to exclude whole families of obstacles (e.g. all the colliders attached to dynamic rigid-bodies). - Its
groupsmethod allows you to filter based on the colliders collision groups. - Its
exclude_colliderandexclude_rigid_bodymethods exclude one collider, and all the colliders attached to one rigid-body. - Its
predicatemethod sets an optional callable to filter-out colliders based on user-defined rules. It is given theColliderHandleand theColliderof each potential obstacle, and returnsTrueto keep it as an obstacle.
warning
If the character-controller is used to move a collider (and the rigid-body it may be attached to) that is present
in the physics scene, the filters must be used to exclude that collider (and that rigid-body) from the set of
obstacles (with QueryFilter.exclude_collider and QueryFilter.exclude_rigid_body) to prevent the character from
colliding with itself.