garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

ShouldCollide output affects weapon traces

Open Kefta opened this issue 6 years ago • 7 comments

Test code:

hook.Add("PlayerSpawn", "", function(pPlayer)
	pPlayer:SetCustomCollisionCheck(true)
end)

hook.Add("ShouldCollide", "", function(pEntity1, pEntity2)
	if (pEntity1:IsPlayer() and pEntity2:IsPlayer()) then
		return true
	end
end)

FireBullets nor engine weapon traces (includes crowbar and physgun, not grav gun) will hit other players when collision is disabled. util.Trace* will still hit other players even with a target player being the filter or the traced entity (in regards to util.TraceEntity), so the collision-trace behaviour is inconsistent.

Kefta avatar Nov 03 '17 10:11 Kefta

This makes me think that if this got fixed, Spectator Ghost Deathmatch thingy scripts would probably break since they probably count on that behavior. But then if it got fixed my script to get proper dynamic collisions between players who wish to not collide with others and players who wish to would actually function properly. Maybe traces should become a hook?

Tenrys avatar Nov 03 '17 11:11 Tenrys

The SpecDM addons I've seen do not rely on this behaviour (https://github.com/Tommy228/TTT_Spectator_Deathmatch/blob/master/lua/weapons/weapon_ghost_base.lua#L343-L355). Making traces call a hook would add quite a bit of overhead.

Kefta avatar Nov 03 '17 11:11 Kefta

well, they don't because it's a custom base. but yeah you're right it would

Tenrys avatar Nov 03 '17 11:11 Tenrys

The custom base still uses FireBullets, which is where this problem applies.

Kefta avatar Nov 03 '17 11:11 Kefta

I think I see why this is implemented now. It's because line traces can't hit child entities, so this collision check allows bullets to hit them at least. I'll see if I can figure out a fix for the root issue.

Kefta avatar May 11 '18 03:05 Kefta

I was incorrect before, this only applies to prop_physics. Still don't know why this is here then

Kefta avatar Jun 19 '18 21:06 Kefta

2022 and this bug is still present.

GrandpaTroll avatar May 19 '22 03:05 GrandpaTroll