Ghosting issue, can someone take a look?
by Vince Gee · in Torque 3D Professional · 01/23/2013 (10:55 am) · 3 replies
Header file
CPP file
Then usage
When the object is created it ghosts to the client, but updates do not, yet I see the server packing them.
class TestGhostObject : public NetObject
{
typedef NetObject Parent;
enum MaskBits
{
TransformMask = BIT( 0 ),
UpdateMask = BIT( 1 ),
Changed = BIT (2),
NextFreeMask = BIT( 3 )
};
DECLARE_CONOBJECT(TestGhostObject);
public:
U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
void unpackUpdate( NetConnection *conn, BitStream *stream );
void inspectPostApply();
TestGhostObject();
};CPP file
IMPLEMENT_CO_NETOBJECT_V1(TestGhostObject);
U32 TestGhostObject::packUpdate( NetConnection *conn, U32 mask, BitStream *stream )
{
Con::printf("Test Ghost Packing Manager! To Connection %i", conn->getId());
U32 retMask = Parent::packUpdate( conn, mask, stream );
return retMask;
}
void TestGhostObject::unpackUpdate(NetConnection *conn, BitStream *stream)
{
Con::printf("Test Ghost Unpacking object Connection %i--->",conn->getId());
Parent::unpackUpdate(conn, stream);
}
void TestGhostObject::inspectPostApply()
{
Parent::inspectPostApply();
if( isServerObject() )
setMaskBits( Changed );
}
TestGhostObject::TestGhostObject()
{
mNetFlags.set( Ghostable | ScopeAlways );
}Then usage
SimObject* tt = Sim::findObject("TestGhost");
TestGhostObject* tgo = dynamic_cast<TestGhostObject*>(tt);
if (!tgo)
{
tgo = new TestGhostObject();
tgo->assignName("TestGhost");
tgo->registerObject(tgo->getId());
}
tgo->inspectPostApply();When the object is created it ghosts to the client, but updates do not, yet I see the server packing them.
About the author
www.winterleafentertainment.com
Torque Owner Demolishun
DemolishunConsulting Rocks!
Edit:
Ooh, check your mTypeMask. That might need to be set to something for it to do updates as well. I am using a SceneObject based object and if that is not set I think it would not update the ghost.
This is part of my init for my object: