Blockcast doesn't appear to respect collision groups

Collision group called ProjectileNone, collides with nothing as seen:
image

There is a table in my serverscript with this information:

local COLLISION_GROUPS = {
	["Always"] = "Projectile",
	["Terrain"] = "ProjectileTerrain",
	["None"] = "ProjectileNone"
}
	local raycastResult = workspace:Blockcast(cframe, self.Hitbox, self.Velocity * FRAMEDELTA, self.RaycastParams)

	if raycastResult then		
		assert(self.RaycastParams.CollisionGroup ~= COLLISION_GROUPS["None"], "Somehow hit something when impossible.")
		print("HIT")
		self.StoppedDueToHit = true
		self:StopShot()
		return
	end

The code should raise an error if the collisiongroup is == “ProjectileNone”

The assertion error is raised:

Thie issue here is, why the hell did raycastResult return anything if there is nothing for it to collide?

2 Likes

The code asserted that RaycastParams.CollisionGroup is not None. Never mind.

assert(false, "OOF")
-- equivalent to
if true then
	error("OOF")
end

Edit.

@SkrubDaNub yes, assert("None" ~= "None", "OOF") --> error. It has to assert that the condition is truthy.

2 Likes

so

assert(self.RaycastParams.CollisionGroup ~= COLLISION_GROUPS["None"], "Somehow hit something when impossible.")

becomes:

if self.RaycastParams.CollisionGroup == COLLISION_GROUPS["None"] then
    error("...")
end
1 Like

Okay, so that means that when the assertion error is raised, then the collision group is:
"ProjectileNone".

If that’s true, then my original question still remains.

1 Like

Oh no, I’m sorry, mixed it up! Yes, that confirms the collision group is None. Silly me. I’ll think about it.

2 Likes

Hi, it’s been 2 hours. Any ideas?

1 Like

Not really. I tried to reproduce the issue to no avail. Quite strange. Perhaps you should investigate what was hit, and what its properties and collision group are.

Any chance the collisions with None are being enabled in a script?

Update. @SkrubDaNub just curious, what was the result of the raycast? Everything works perfectly in an empty place, so there must be a hidden detail in the code.

1 Like

None shouldn’t collide with anything. I’ve sent the properties in the original post.

I’ll do some searching through my code if I’ve done what you suggested. Many thanks.

If I come up with anything I’ll let you know.

1 Like

The raycastResult is what you would expect on a hit. Instance isn’t nil.

If the BaseParts that have their collision group set to ProjectileNone also have their CanCollide property set to false, setting their CanQuery property to false should make all raycasts ignore them

All baseparts are set to “Default” by default, which the collisiongroup ProjectileNone ignores.

I can’t set the baseparts .CanCollide because… I don’t want to fall through the floor.

I think this is a situation where I’d recommend reorganizing your collision groups. BaseParts that you’d wish for raycasts to ignore should ideally be kept in a collision group separate from BaseParts that raycasts can detect

1 Like

There is no separation. I simply want the blockcast to ignore all collisiongroups. (Though in hindsight, I might just do away with the raycast in the first place).

Actually, I’ll do just that. I’m just going to not do the raycast at all.

Update: turns out I set the part to a collisiongroup that wasn’t defined which means everything collided with it by default.

Sorry for wasting all of your time!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.