Game Development Community

Ghosting issue, can someone take a look?

by Vince Gee · in Torque 3D Professional · 01/23/2013 (10:55 am) · 3 replies

Header file
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.

#1
01/23/2013 (5:04 pm)
All I can think is that the status is not changing so it is not sending an update. Does the Parent::packUpdate send anything? Or should it be forcing the changes to occur by calling inspectPostApply?

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:
mNetFlags.set( Ghostable | ScopeAlways );

mTypeMask |= StaticObjectType | StaticShapeObjectType;
#2
01/24/2013 (10:32 am)
Took me a while to figure it out, it was a class somewhere else which was corrupting the network stack by doing a buffer overrun. Fixed that and magically all my errors went away.
#3
01/24/2013 (11:18 am)
Ahhh, I was totally about to guess that. ;) Glad you figured it out.