Props auto disable collisions?

How would I make it so props automatically have their collisions disabled when being physgunned, and when inside another prop if both aren’t frozen?

If you know lua, you’ll need these:

If you don’t - You can hire someone to write the script for you.

As yes the wonderful scriptfodder.

Maybe I would if I wasn’t banned from it.

[editline]27th September 2015[/editline]

I tried doing this, but it does literally nothing.

/addons/propcollide/lua/autorun/server/propcollide.lua should do it right?


function AutoNoCollide( ent )
	if ent == "prop_physics" then
		Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
	end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )

You are executinng SetCollisionGroup on an unexistant entity (Entity)

They say to nudge people in the right direction — not shove them off a bridge :v:

Anyway, make sure you add a PhysgunDrop hook, too, to set it to its original collision group, unless that’s not what you want.

I know, I’m just testing this first.



function AutoNoCollide( ent )
	if ent == "prop_physics" then
		ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
	end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )

Doesn’t work either. Pretty sure I have to define ent, can someone help me?

Your if check is wrong, you have to use this

Entity:GetClass

Your point being? I gave him a set of links to functions/hooks he needs.

No no, it was supposed to be a joke. You very “subtly” hinted at him hiring you to do the script for him, but I guess it wasn’t executed very well.

Got this, getting attempt to index global LocalPlayer (nil)


function AutoNoCollide( ent )
	if ( LocalPlayer:GetEyeTrace().Entity == "prop_physics" ) then 
		ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
	end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )

And you have already the ent in the function,
ent:GetClass() == “prop_physics”

LocalPlayer is a function, not a variable.

Did you read the wiki page for this hook? As it takes the entity using the physgun as a first argument, so no need for localplayer business


function AutoNoCollide( ent )
	if ent:GetClass() == "prop_physics" then 
		ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
	end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )

Does nothing.

Because the first argument is the player, THEN the entity, jesus!

What?

Did you learn GLua/Lua at all? Functions got arguments, and the PhysgunPickup got two arguments, the first is the player picking the entity up, the second is the entity that has been picked up.

Edit: Functions count to the basics of lua…

I couldn’t care less about him hiring me.

How would I make it so if props are welded together all the welded props are also nocollided while being physgunned? http://pastebin.com/YcskyzEw

The Wiki is a wonderful place. A quick search for “constraint” reveals the wonderful function constraint/GetAllConstrainedEntities which returns a table of all the entities constrained to a specific entity (suprising, I know). It even includes a code snippet which loops through each entity. This can be re-purposed for what you want to achieve.



-- Loop through all the entities in the system
for _, Entity in pairs( constraint.GetAllConstrainedEntities( trace.Entity ) ) do
  DoRemoveEntity( Entity )
end