Entity turning non-solid when dropped?

So I’ve got this entity in my gamemode: a flag! (Well actually it’s a ball but that doesn’t matter) But if you pick it up with the gravity gun, and die while holding it, the entity turns into some sort of ghost?! You cannot shoot it, can’t pick it up or punt it, can’t hit it with the crowbar, it only collides with the world! How can I fix this incredibly annoying bug?

Have you done anything to it when it is picked up, such as changing its collision group? Have you tried changing the collision group back when it’s dropped?

Did that, no success.

Does anyone know a solution to this problem? It’s breaking my game, because if players can’t pickup the flag, the whole game gets ruined!

I guess it’s a SENT? What is your ENT.Type and ENT.Base?

ENT.Type = “anim”
ENT.Base = “base_anim”

I’m just gonna post the entity’s whole init.lua here:

AddCSLuaFile( “cl_init.lua” )
AddCSLuaFile( “shared.lua” )

include( “shared.lua” )

function ENT:Initialize()

self.Entity:SetModel( "models/fw/fw_flag.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )  

local phys = self.Entity:GetPhysicsObject()
if ( phys:IsValid() ) then
	phys:Sleep() --ZZZZZzzzzzz.....


function ENT:OnTakeDamage( dmg )
self.Entity:TakePhysicsDamage( dmg )

local lastcheck = CurTime()

function ENT:Think()

if ( lastcheck < CurTime() ) then
	if ( self.Entity:IsPlayerHolding() ) then
		if ( self.Entity:GetNWBool( "Check", false ) ) then
			lastcheck = CurTime() + 1 --Add points every second if someone is holding the ball
			team.AddScore( self.Entity:GetNWEntity( "CheckHolder", NULL ):Team(), 1 )
		if ( self.Entity:GetNWVector( "RColor", Vector( 1, 1, 1 ) ) != Vector( 1, 1, 1 ) ) then
			self.Entity:SetNWVector( "RColor", Vector( 1, 1, 1 ) ) --Make it white if dropped!


function ENT:PhysicsUpdate()

Looks like nobody knows how to fix it. I’ll give you guys some more information…
This a part of init.lua, maybe I’m doing something wrong here?

function GravityDropFunction( ply, ent )
ent:SetNWVector( “RColor”, Vector( 1, 1, 1 ) ) --Color the flag white
ent:SetNWBool( “Check”, false ) --Stop adding seconds to the team hold-on time
TellEveryone( “DROP”, ply:Team() ) --Flag has been dropped!

function GravDrop( ply, ent )
if ( ent:GetClass() == “fw_flag” ) then
GravityDropFunction( ply, ent )
return false

hook.Add( “GravGunOnDropped”, “Color0r2”, GravDrop )

function Death( ply, inflictor, attacker )
local ent = ents.FindByClass( “fw_flag” )[1]
if ( !ValidEntity( ent ) ) then return end
if ( ent:GetNWEntity( “CheckHolder”, NULL ) == ply and ent:IsPlayerHolding() ) then
GravityDropFunction( ply, ent )

hook.Add( “PlayerDeath”, “Dropp0r”, Death )[/lua]

In the GravityDropFunction try adding
ent:SetOwner( ent );

Now the ball can be shot after dieing while holding it, but I still can’t pick it up and if I touch it, the game locks up?! :wtc:

I think I know the answer: the entity is not synchronized with the server! When walking into it, the client prediction thinks it’s solid, but on the server you can walk through it. How would I fix this?

SetOwner disables collision between the owner and the owned, which is not the goal here if I read correctly.

If the player dies while holding the ball, you could delete that ball and make a new one in the position where that ball got deleted.

When a player picks up an object with the gravity gun they are set as the owner… which is why I had him try removing the owner.

Although that may work, it totally ignores the problem at hand and IMO is a piss poor solution.


Read at the bottom under Additional Notes, do those problems sound familiar?

Ah, so you were gong to set the owner to itself? I didn’t see that, and I have no idea what that would do.

Why does it ignore the problem at hand? The problem is the frozen and non-solid ball. If you destroy that one and create a new one, it will be solid and not frozen.

I can’t recreate the ball at run time. There’s lots of networked variables. And the velocity would also be reset. But I think the problem is that the client is out of sync with the server. How do it synchronize it?!

Try setting the owner to NULL instead.


Alright, this worked for me:

hook.Add( “DoPlayerDeath”, “test”, function( a, b, c ) a:StripWeapon( “weapon_physcannon” ) end );

This. Setting the entity as its own owner is probably a really bad idea.

Yea, I couldn’t remember if it was self or NULL.

Thank you so much! :buddy: