garrysmod-issues
garrysmod-issues copied to clipboard
ShouldCollide output affects weapon traces
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.
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?
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.
well, they don't because it's a custom base. but yeah you're right it would
The custom base still uses FireBullets, which is where this problem applies.
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.
I was incorrect before, this only applies to prop_physics. Still don't know why this is here then
2022 and this bug is still present.