Player Collisions

is there a way to make a player NOT collide with members of his own team, but DO collide with member of another?



function GM:ShouldCollide(ent1, ent2)
if ( ent1:IsPlayer() and ent2:IsPlayer() ) then
return ent1:Team() != ent2:Team()
return true


_nonSENSE: Where we I put that code in? Like what folder if it is for zombie survival?

init.lua or shared.lua


I was reading the notes for that function and I saw “If you return different values between two same entities - you can break physics engine.” would that be like doing:

[lua]function GM:ShouldCollide(entity1, entity2)
if (entity1:SteamID() == “steamid” && entity2:SteamID() == “samesteamid”) then
return true

Something like that?

No, that would be like doing something like this:

[lua]function GM:ShouldCollide(e1,e2) return e1:EntIndex() > e2:EntIndex() end[/lua]

When called with e1,e2, it will return false, when called with e2,e1, it will return true, breaking the physics engine.

Oh I see.That makes sense.

Where would I find that file? I am completely new at this so I will need to know the file.

Open your eyes? It’s right there.

In your garrysmod folder, go to garrysmod/gamemodes/zombiesurvival/gamemode/shared.lua

I’m not sure about the zombiesurvival folder name.

Thank you I will try when I get home.

[editline]6th January 2011[/editline]

IT WORKS :smiley: Thanks everyone.