In my gamemode’s shared.lua:
function GM:ShouldCollide( ent1, ent2 ) // Players that are stuck in each other, like after spawning if (ent1:IsPlayer() and ent2:IsPlayer()) then local ent1pos = ent1:GetPos() local ent1obbmin = Vector(-16,-16,0)*0.95 local ent1obbmax = Vector(16,16,72)*0.95 local entl = ents.FindInBox( ent1pos+ent1obbmin, ent1pos+ent1obbmax ) if (table.HasValue(entl, ent2)) then local normal = (ent1:GetPos()-ent2:GetPos()):GetNormal() if (math.abs(normal.x) < 0.2 and math.abs(normal.y) < 0.2) then normal.x = 1 end ent1:SetVelocity( normal * 70 ) ent2:SetVelocity( normal * -70 ) return false end end return true end
Basically what it does it pushing two stuck players away from each other. There’s a strange issue however that occurs when I test on a listen server with bots. If this code gets called ‘too often’ (doesn’t seem to happen directly) the physics engine seems to break and all physics props start acting like the ground is made of water or something.
Recording here: http://dl.dropbox.com/u/11217331/Screens/bug.gif (12MB gif)
The physics remain broken even after starting a completely different map and gamemode. I can’t fix it without restarting Garry’s Mod completely.