Can't get CollisionGroups working with KinematicCharacterController #480
-
I'm trying to use the commands.spawn((
TransformBundle::default(),
Collider::capsule(
Vec3::new(0.0, -CHARACTER_END_HEIGHT, 0.0),
Vec3::new(0.0, CHARACTER_END_HEIGHT, 0.0),
CHARACTER_RADIUS,
),
KinematicCharacterController::default(),
RigidBody::KinematicVelocityBased,
CollisionGroups::new(
Group::from_bits(0).unwrap(),
Group::from_bits(0).unwrap(),
),
)); In the full example I have a few different groups and filters to test things out, but here I'm attempting to do a sanity check and have the character collide with nothing, with no groups and no bits set in the filter. However even with this setup, the characters collide with everything else in the world, other characters, static objects, and dynamic rigidbodies. I also noticed that the I suspect that I'm just missing some component that's needed alongside |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solved my own problem after discovering the let filter = CollisionGroups::new(
Group::from_bits(0).unwrap(),
Group::from_bits(0).unwrap(),
);
commands.spawn((
TransformBundle::default(),
Collider::capsule(
Vec3::new(0.0, -CHARACTER_END_HEIGHT, 0.0),
Vec3::new(0.0, CHARACTER_END_HEIGHT, 0.0),
CHARACTER_RADIUS,
),
KinematicCharacterController{
filter_groups: Some(filter),
..default()
},
RigidBody::KinematicVelocityBased,
filter,
)); |
Beta Was this translation helpful? Give feedback.
Solved my own problem after discovering the
filter_groups
field onKinematicCharacterController
. In order to get collisions filtering the way I expect, I needed to set thefilter_groups
field AND insert aCollisionGroups
component using the same values. If I setfilter_groups
without the component, not only would it collide with everything but other fields such asapply_impulse_to_dynamic_bodies
would stop working and no longer apply.