Player Nocollide issues

Currently, I have it set to set the players collision group to WEAPON on spawn; but sometimes it bugs out, the collision group breaks and players get stuck inside of each other for some reason. I was wondering, if using [lua] for k,v in pairs(player.GetAll()) do
if v:IsPlayer() and v:IsValid() then
end[/lua] every time somebody spawned is… the best way of doing it?

My players are on different teams sometimes, so SetNoCollideWithTeammates won’t work.

The collision group is never changed from players in my code, nor any addons, so I have no clue why they get stuck in each other sometimes.

[lua]hook.Add( “OnEntityCreated”, “Enable Custom Collision Check”, function( ent )
if ent:IsPlayer() then
ent:SetCustomCollisionCheck( true )
end )

hook.Add( “ShouldCollide”, “Disable Player Collisions”, function( ent1, ent2 )
if ent1:IsPlayer() and ent2:IsPlayer() then
return false
end )[/lua]

This will disable collisions for players, however it will also stop them from getting hit with bullets.

If you need bullets to hit, you can probably continue using your collision groups, but put it in a PlayerSpawn hook.

[lua]hook.Add( “PlayerSpawn”, “Disable Player Collisions”, function( ply )
ply:SetCollisionGroup( COLLISION_GROUP_WEAPON )
end )[/lua]

What’s the difference between if I had it in the Spawn function, Loadout, etc… rather than a hook?


I’ve already had it in the player spawn hook; and the player loadout hook, neither with success. Both times somebody always gets stuck for some reason. Thus, why I made this version, but still…

Edit: For custom collision checks; can’t we just return true after returning false for the Player checks to make bullets and whatnot collide correctly?


As for the collision groups, you may want to try setting the players to COLLISION_GROUP_DEBRIS_TRIGGER instead and see if that helps.

I found the problem, for some reason, when I change something in the FPP menu, collision groups get reset.

Thanks for your help :smiley: