Player to Player NoCollide

I have been messing with this for hours and I can’t come up with an answer. Only way I could get no collision player to player to work was ply:SetCustomCollisionData() which I don’t think you can disable?

I stuck this bit of code in the DeathRuns shared.lua

function GM:ShouldCollide( ent1, ent2 )

	if ( ent1:IsPlayer() and ent2:IsPlayer() ) then
		return false
	return true

Although it appears adding this bit of code does nothing from what I can tell. Any ideas??

Thanks for any information!

It’s returning false, then continuing on with the code to return true, I think is what is happening. Try removing the return true, because it should return true by default anyway.

Returning stops the rest from running.

You have to use:

function GM:ShouldCollide(ent1, ent2)
return (ent1:IsPlayer() and ent2:IsPlayer())

You could also use SetNoCollideWithTeammates( true ) if you want them to collide with enemies.

I switched my GM:ShouldCollide function to match yours. Also I was doing ply:SetCustomCollisionCheck(true) and it worked. Then when I did ply:SetCustomCollisionCheck(false) it did nothing and players could still walk through each other. How would I go about disabling it?

I’m trying to make it so a specific team does not collide with any other player. I know it sounds like terrible logic but there is a good reason, I will save you from my rambling and not go into details :p.

Thanks for the speedy responses guys!

I don’t think you’re setting it up right.
hook.Add(“PlayerSpawn”, “CollisionCheck.PlayerSpawn”, function(ply)

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

Thanks Brandon its working now! I collide with all players until I call my function thats sets ply:SetCustomCollisionCheck(true) then I can walk though all players.

I tried hooking into PlayerDeath and setting it to false but it didn’t do anything. How would I go about disabling this so you do not walk though players when the next round starts?

Also thanks for the help!!

You’re going to have to do this logically.

Setting it to false isn’t working because it’s being set to true when a player spawns right?

You’re going to have to come up with your own way unless you can explain exactly what you want to do.

Here let me brief you on the task at hand. I am making it so when a player types /ghost in chat they will respawn as a “ghost” and get still play instead of sitting in spec until the round ends. Everything is working great but I need to make it so the ghosts can not interact with real players.

I am currently setting ply:SetCustomCollisionCheck(true) when they player types /ghost and they get spawned.

I figured I could do something along the lines of this in the GM:ShouldCollide function:
if !ent1:Team() == TEAM_GHOST then return end

I’ve tried that a few different ways, I couldn’t get it to work.

[editline]17th October 2013[/editline]

Know whats strange, I commented out ply:SetCustomCollisionCheck(true) and after you die and respawn all of a sudden the custom collision check is working. It seems that the PlayerDeath hook setting it to false is also enabling it for some odd reason. Is this function broken, or does it just not work like I’m thinking it should?

You have to do it when the entity is created, not when they type a command. Either in an EntityCreated hook or PlayerSpawn hook. Just use this:
[lua]hook.Add(“PlayerSpawn”, “PlayerSpawn_Ghosts”, function(ply)

hook.Add(“ShouldCollide”, “ShouldCollide_Ghosts”, function(ent1, ent2)
return (ent1:IsPlayer() and ent2:IsPlayer() and (ent1:Team() == TEAM_GHOST or ent2:Team() == TEAM_GHOST))

WOOHOOO! Got it working! Thanks for the help Brandon and Ozymandias, It was very painful but I understand how this function works now. Thanks for the help!!!

Working as intended:

return (ent1:IsPlayer() and ent2:IsPlayer() and ent1:Team() != TEAM_GHOST and ent2:Team() != TEAM_GHOST)

[editline]18th October 2013[/editline]

One small problem, I don’t know what they are called in mapping, but the movable brushes in DR? All players fall through the brushes that make up the traps on DeathRun. I don’t have the slightest clue to why this would be happening. =X

[editline]18th October 2013[/editline]

I found out the players are falling through this:

Entity [175][func_breakable]