Game Development Community

SetControlObject oddity

by gamer · in Torque Game Engine · 01/03/2007 (1:15 pm) · 3 replies

I am having an issue where if I call ServerConnection.setControlObject(%x) on the client side, the controlObject gets reset back to the old one afterwards in void GameConnection::readPacket(BitStream *bstream).
Here is the relavant part in readPacket. my question is why is the controlObject being reset to the old one? what can I do about it?
thanks

void GameConnection::readPacket(BitStream *bstream){
.
.
.
S32 gIndex = bstream->readInt(NetConnection::GhostIdBitSize);
            ShapeBase* obj = static_cast<ShapeBase*>(resolveGhost(gIndex));
			if (mControlObject != obj){
				Con::printf("in read packet    setControlObject %d", obj->getId());          
				setControlObject(obj);
			}

#1
01/03/2007 (5:07 pm)
Sorry I made a typo in my post, it was ServerConnection.setControlObject(%x) not getControlObject(%x).
It turns out that a workaround is this:
if (mControlObject != obj){
				Con::printf("in read packet    setControlObject %d", obj->getId());          
				if(mControlObject.isNull())setControlObject(obj);
			}
so basically you wont be able to change your mControlObject unless it's null. I am not sure what was causing my problem in the first place and not sure what side effect this fix will have...
maybe someone can help me out.
#2
01/03/2007 (5:57 pm)
You might try changing the control object on the server side instead.
#3
01/04/2007 (10:57 am)
Thanks, setting control object on the server side seems to solve the problem. But another issue stems from this is that the control object in this case is the camera, and two client can't share the same camera, so what I do is to copy one client's camera and then set the copy as the control object of another client. I copied the camera transform,fov, what else do I need to copy to make sure they are the same? Because right now the copied camera is always at player's feet.