#QueryFilter based on components

10 messages · Page 1 of 1 (latest)

gilded minnow
#

Hi! I'm using rapier, and I'm trying to cast a ray that only cares about colliders with a given component.

I'm wondering what would be the idiomatic/efficient way to achieve this. Should I use a collision group instead of a component? If so, how would that look?

Thanks!

normal thistle
#

Based on my limited knowledge, this definitely sounds like a job for collision groups. That's exactly what they're designed for, and since they are a rapier feature, they'll be the most performant (I assume)

gilded minnow
#

@normal thistle One thing that wasn't clear to me is: by default, are any of the collision groups in use? Like is everything Group1 by default?

normal thistle
gilded minnow
#

oh? so if I want my ray-cast to only interact with one singular group, I have to make sure to always set the collider group manually for every single collider?

#

otherwise, every collider would be part of the particular group too

normal thistle
#

You'd do something like this:

  1. Determine the groups you want to use. You may have e.g. a 'world' group (like terrain), and 'enemy' group, etc.
  2. Put all your colliders into one or more of the groups from step 1 (i.e. override the default behaviour of belonging to every group0
  3. Set your ray's filter to only the group that you want it to interact with
gilded minnow
#

That makes sense

#

Thank you, much appreciated.