Skip to main content

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 (a QueryFilterFlags, also set by constructors like QueryFilter.exclude_dynamic()) allow you to exclude whole families of obstacles (e.g. all the colliders attached to dynamic rigid-bodies).
  • Its groups method allows you to filter based on the colliders collision groups.
  • Its exclude_collider and exclude_rigid_body methods exclude one collider, and all the colliders attached to one rigid-body.
  • Its predicate method sets an optional callable to filter-out colliders based on user-defined rules. It is given the ColliderHandle and the Collider of each potential obstacle, and returns True to 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.