I have a RootPart CollisionGroup. It has CanCollide and all that true. I’ve turned its collisions with the player and other groups off tho (still on for default)
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Include
Params.CollisionGroup = "EnemyRootPart"
local Test = workspace:GetPartBoundsInRadius(self.Instance:GetPivot().Position, Radius, Params)
print(Test)
The wording the hub is really poor. What does it mean by “not collide with this group”, what group?
“Not collide with this group” in your case means collision groups that cannot collide with EnemyRootPart (so groups that can’t collide with EnemyRootPart are Character and Enemy, these will be omitted from the spatial query 100% of the time with no exceptions, regardless of whether or not they are found inside of params.FilterDescendantsInstances, and regardless of the FilterType)
When your filtertype is include, and you provide a collision group, it means only parts that have a collision group that can collide with EnemyRootPart and are inside of the params.FilterDescendantsInstances will be considered for the spatial query.
When your filtertype is exclude, and you provide a collision group, it means only parts that have a collision group that can collide with EnemyRootPart and are not found inside of the params.FilterDescendantsInstances will be considered for the spatial query.
How do I get parts within a radius then? I figured these spatial queries (GetPartBoundsInRadius) would get any and all parts within a radius of a position, and would take into account only parts with the EnemyRootPart collisiongroup. I shouldn’t need FilterDescendantsInstances? It should just search for all parts in a radius find x amount of parts, check if they have collision group and if not ignore them
1- Set FilterType to exclude because you don’t want to set a whitelist of parts – I’m assuming the issue here is that you’re receiving an empty list of parts, this is the reason. It’s only going to query parts that are in the whitelist (which is an empty list in your case from your code sample) and have a collision group that is collidable with the EnemyRootPart
2- Assuming you want a list of parts within the radius that can collide with EnemyRootPart, you would set the OverlapParams’ CollisionGroup to EnemyRootPart so it queries all parts from the Default, EnemyIgnore, and EnemyRootPart collision groups
that’d just get all the parts that I don’t want. and while I could just do FilterDescendants on models, I’d getting hundreds of parts that aren’t necessary. I only care about the HRP, so table should only be 5-10 objects, not hundreds
Yeah, that would work, setting the OverlapParams’ CollisionGroup to an empty collision group that can only collide with the EnemyRootPart.
For an alternative that doesn’t rely on an empty collision group, you could also go back and set the CollisionGroup to EnemyRootPart, re-set the filter type to include, then just add a list of the root parts to the filter, listen for new ones to be added ofc then add them to the filter via :AddToFilter.