I'm trying to use the filter_groups property to filter some obstacles but I don't know why nothing is filtered:
fn setup(
mut commands: Commands,
mut atlases: ResMut<Assets<TextureAtlas>>,
server: Res<AssetServer>,
) {
let image_handle: Handle<Image> = server.load("spritesheets/spritesheet_Mario.png");
let texture_atlas = TextureAtlas::from_grid(
image_handle,
Vec2::new(SPRITE_MARIO_WIDTH, SPRITE_MARIO_HEIGHT),
SPRITESHEET_COLS,
SPRITESHEET_ROWS,
Option::from(Vec2::new(SPRITE_PADDING_X, SPRITE_PADDING_Y)),
Option::from(Vec2::new(SPRITE_OFFSET_X, SPRITE_OFFSET_Y)),
);
let atlas_handle = atlases.add(texture_atlas);
commands
.spawn(SpriteSheetBundle {
sprite: TextureAtlasSprite::new(SPRITE_IDX_STAND),
texture_atlas: atlas_handle,
transform: Transform {
scale: Vec3::new(
SPRITE_RENDER_WIDTH / SPRITE_MARIO_WIDTH,
SPRITE_RENDER_HEIGHT / SPRITE_MARIO_HEIGHT,
1.0,
),
translation: Vec3::new(WINDOW_LEFT_X + 300.0, WINDOW_BOTTOM_Y + 300.0, 0.0),
..Default::default()
},
..Default::default()
})
.insert(RigidBody::KinematicPositionBased)
.insert(Collider::cuboid(
SPRITE_MARIO_WIDTH / 2.0,
SPRITE_MARIO_HEIGHT / 2.0,
))
.insert(KinematicCharacterController{
filter_groups: Option::from(CollisionGroups::new(
Group::GROUP_1,
Group::ALL, // Even if I try to filter ALL
)),
..Default::default()
})
.insert(Direction::Right)
.insert(ActiveEvents::COLLISION_EVENTS)
.insert(ActiveHooks::MODIFY_SOLVER_CONTACTS);
}
with filter_flags: QueryFilterFlags::all() it works but not when I try to use filter_groups.
I have to use filter_groups instead of filter_flags because I want to filter SOME of Fixed obstacles.
OK the second parameter here is a
whitelist:So here for example will interact with every obstacles.
We can put Group::NONE and the
entitywill NOT interact with any colliders:So if we want to exclude a group to interact with an entity we can do it like this: