Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.
When a part belongs to a collision group that cannot collide with Default, it can never be hit by any of the FindPartOnRay methods. Normally, I would expect raycasting results to be independent of a part’s collision group.
How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.
This can be consistently replicated. Here’s a sample script. Paste this in a script on an empty baseplate, and hit play. It will print false. Commenting out the indicated line will make it print true instead.
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CFrame = CFrame.new()
local DEFAULT = "Default"
local TESTGROUP = "TestGroup"
local PhysicsService = game:GetService("PhysicsService")
PhysicsService:CreateCollisionGroup(TESTGROUP)
PhysicsService:CollisionGroupSetCollidable(DEFAULT, TESTGROUP, false) -- Commenting this out will make it print true instead.
PhysicsService:SetPartCollisionGroup(part, TESTGROUP)
local ray = Ray.new( Vector3.new(0, 10, 0), Vector3.new(0, -10, 0) )
local hit = workspace:FindPartOnRayWithWhitelist(ray, {part})
print(hit == part) -- Prints false.
When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.
It happens on the current version of studio as of the posting of this bug report. (0.301.1.141504)
I see this as a useful feature for collision groups, not a bug. Although, it would be nice to have control over the physics group that the raycast is considered to be in, rather than it always detecting hits as if it were in the default collision group.
If you just wanted to raycast through something, just add it to the ignore list if you’re using FindPartOnRayWithIgnoreList, or don’t put it in the whitelist when you’re using FindPartOnRayWithWhitelist
Anyway, the reason why this was bothering me in particular was because of this usecase:
I want to have certain parts of my character non-collidable with the level.
My game uses raycasts for projectiles.
Now, my hitboxes of my character is all wrong.
One could weld parts onto the character, but that’s unnecessarily cumbersome. One could also add the level to a different CollisionGroup, but if that’s the case why even bother with the default collision group.
And, as I’ve mentioned, from a developer’s perspective, it makes no sense for collision groups to influence raycasts.
Just because it’s useful doesn’t mean it’s not a bug. This should be fixed, and we should have a proper way of associating a raycast with a collision group.
Yeah, that’s what I meant. Having a proper way to associate a raycast with a collision group (which would default to the default collision group) would fix this.
Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.
I have a model that is part of a CollisionGroup. FindPartOnRayWithWhitelist(), given the children of the model as the whitelist, does not return any parts from the model when used with a ray that intersects the model’s parts.
If I don’t put the parts in a collision group, the function works as advertised.
How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.
This happens always.
To reproduce, create a model and place its parts in a CollisionGroup. Then use FindPartOnRayWithWhitelist() with the model’s children as the whitelist. The function will not return an intersected part.
Where does the bug happen (www, gametest, etc) Is it level-specific? Is it game specific? Please post a link to the place that exhibits the issue.
I was using collision filters in my game to patch a flinging bug, only to realise that raycasts still don’t work on items when they have a collision filter set on them outside of ‘Default’. Please add functionality to support collision groups.
I started using this bug as a feature, lol. I add things such as particle emitters and bullets to a collision group that doesn’t collide with default so that i don’t have to include them in an ignore list while raycasting.
This bug is severely hindering my work, as I need Default group parts to not collide with themselves; this means that all parts in the Default group cannot be interacted with by the client, as Mouse.Target ignores any parts that do not collide with the Default group.
PLEASE fix this
It makes players have invincibility in my game when they are in the elevator (since they are set to not collide with anything while in the elevator)
It’s documented in the wiki, so this “bug” is officially a feature now. It’s been documented for a while now, too, and I know several games which actually use this feature.
do you know of any way to bypass it?
my current workaround will be to make a no-plr+zombie collision group and if I end up having to have roblox physically simulated [projectile] debris, a no-plr+zombie+debris collision group as well as a debris collision group
and more and more collision groups for other cases lol
iirc setting CanCollide property of each part under the character to false every step works, too, without affecting raycasting.
local character = script.Parent
game:GetService("RunService").Stepped:Connect(function()
for _, v in next, character:GetDescendants() do
if v:IsA("BasePart") then
v.CanCollide = false
end
end
end)
Disconnecting this makes the character collidable with the environment again.
it only works sometime for me actually (I mean falls through the ground too), i don’t know if it needs to be server script/local script and on heartbeat/on stepped (I did all of the above)
but it seems a little unstable (because it only works sometimes) and I don’t think I would do it because of that and also because I’m generally not a fan of continuous updating
Oh yeah, this doesn’t let you fall through the ground but still lets you walk through walls. If you want to fall through the ground, then I don’t know of a way to do that off the top of my head.
Here’s another solution: Make only the HumanoidRootPart non-collidable with Default on the server, and then run the stepped loop above locally. This will make the character fall through the ground while still letting it be hittable by raycasts.