Thanks for your replies.
I just tried ENT:InitializeAsClientEntity() in case it has been fixed and it seemed to do nothing of any use.
It looks like using an effect with a client-side prop_dynamic will be the best option for me, thanks for the suggestion on that I had forgotten about effects.
Regarding the error it’s self, I believe entity factories are created when you (In C++.) use the macro LINK_ENTITY_TO_CLASS(), which I assume isn’t getting called on the client. (I don’t know if there’s a specific client-side version of that macro or if you use the same one.) I’d guess that was what ENT:InitializeAsClientEntity() was meant to fix, but as ENT:Initilize() never gets called due to the entity not having a factory, it never gets linked. As such I tried running ENT:InitializeAsClientEntity() outside of the function but I guess I was calling it wrong or it doesn’t work how I expected.
Taken from the Orange Box SDK:
bool C_Gib::InitializeGib( const char *pszModelName, Vector vecOrigin, Vector vecForceDir, AngularImpulse vecAngularImp, float flLifetime )
if ( InitializeAsClientEntity( pszModelName, RENDER_GROUP_OPAQUE_ENTITY ) == false )
SetAbsOrigin( vecOrigin );
SetCollisionGroup( COLLISION_GROUP_DEBRIS );
PhysModelParseSolid( tmpSolid, this, GetModelIndex() );
m_pPhysicsObject = VPhysicsInitNormal( SOLID_VPHYSICS, 0, false, &tmpSolid );
if ( m_pPhysicsObject )
float flForce = m_pPhysicsObject->GetMass();
vecForceDir *= flForce;
m_pPhysicsObject->ApplyForceOffset( vecForceDir, GetAbsOrigin() );
m_pPhysicsObject->SetCallbackFlags( m_pPhysicsObject->GetCallbackFlags() | CALLBACK_GLOBAL_TOUCH | CALLBACK_GLOBAL_TOUCH_STATIC );
// failed to create a physics object
SetNextClientThink( gpGlobals->curtime + flLifetime );
Notice their call to InitializeAsClientEntity() has two parameters. Regardless I don’t think it would fix the factory issue, I’ll look for the factory now.
The static method CreateClientsideGib() seems to be their “factory”, but there is no way that I know of to create a method like this from Lua.
C_Gib *C_Gib::CreateClientsideGib( const char *pszModelName, Vector vecOrigin, Vector vecForceDir, AngularImpulse vecAngularImp, float flLifetime )
C_Gib *pGib = new C_Gib;
if ( pGib == NULL )
if ( pGib->InitializeGib( pszModelName, vecOrigin, vecForceDir, vecAngularImp, flLifetime ) == false )