Ghosting Props

Hi I would like help with creating a script that while holding a prop with your physgun it will always be ghosted while your holding it.

Thanks very much I just need guided in the right direction.

I have seen some servers that have this, i was also wondering how they do this.

Well yeah me too. If you find out anything please share your information. Thanks

Well, you could start by doing something like this:


hook.Add("PhysgunPickup", "Pickup", function(ply, ent)
	if ent:GetClass() == "prop_physics" then
		ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
		local entcol = {ent:GetColor()}
		ent:SetColor(255,255,255,150)
	end
end)

hook.Add("PhysgunDrop", "Drop", function(ply, ent)
	if ent:GetClass() == "prop_physics" then
		ent:SetCollisionGroup(COLLISION_GROUP_NONE)
		ent:SetColor(entcol)
	end
end)

Which ‘should’ set the prop to not have any collisions, except for the world and static objects, upon pickup, and then give back its collisions to everything when dropping it. It also sets its alpha down to give it that ‘ghost’ effect. Untested, so I have no idea if this works.

Only problem with that is if you pick the prop up and freeze it in someone they get stuck

Edit: Also this script does work so thanks :slight_smile:

I was thinking that, but forgot to add it. Lol.


hook.Add("PhysgunPickup", "Pickup", function(ply, ent)
	if ent:GetClass() == "prop_physics" then
		ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
		local entcol = {ent:GetColor()}
		ent:SetColor(Color(255,255,255,150))
	end
end)

hook.Add("PhysgunDrop", "Drop", function(ply, ent)
	if ent:GetClass() == "prop_physics" then
		ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
		ent:SetColor(Color(255,255,255,150))
	end
end)

hook.Add("OnPhysgunFreeze", "Freeze", function(ply, ent)
	if ent:GetClass() == "prop_physics" then
		timer.Simple(5, function(),
			ent:SetCollisionGroup(COLLISION_GROUP_NONE)
			ent:SetColor(entcol)
		end)
	end
end)

This one should fix the prop trapping problem…

Thank you so much for this script

this script doesn’t seem to be working in autorun/server. any ideas?

Yea, I just tested it on my development server. I was having problems with it as well, not sure what the problem is… It looks fine to me…

(Untested)
[lua]
hook.Add(“PhysgunPickup”, “Pickup”, function(ply, ent)
if ent:GetClass() == “prop_physics” and !ent.ghost then
ent.ghost = ent:GetCollisionGroup( )
ent:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
ent.entcol = ent:GetColor()
ent:SetColor(Color(255,255,255,150))
end
end)

hook.Add(“PhysgunDrop”, “Drop”, function(ply, ent)
if ent:GetClass() == “prop_physics” and ent.ghost then
ent:SetCollisionGroup(ent.ghost)
ent:SetColor(ent.entcol)
ent.ghost = nil
end
end)

hook.Add(“OnPhysgunFreeze”, “Freeze”, function(ply, ent)
if ent:GetClass() == “prop_physics” and ent.ghost then
timer.Simple(5, function(),
ent:SetCollisionGroup(ent.ghost)
ent:SetColor(ent.entcol)
ent.ghost = nil
end)
end
end)
[/lua]

  • Fixed PhysgunDrop ghosting it
  • Fixed a possible color bug
  • Added support for other collision groups