Game Development Community

Problem with own Shapebase derived object

by Matt Huston · in Torque Game Engine · 12/15/2007 (11:29 am) · 5 replies

I am writing some code for a door that is derived from ShapeBase. However I am having a problem updating a variable during runtime.

I have a variable called mOpen which when true, the door will start rotating open. mOpen is checked in the advanceTime(F32 dt) function. I update the variable to true via a consoleMethod from script. However, upon printing the mOpen varable in the advanceTime function, the variable is not updated. However, when I open the Mission Editor and click on the door object, the variable has updated and the door begins to open.

The door also updates if I set mOpen to be true starting the game.

#1
12/15/2007 (12:35 pm)
Is the console method getting called on the server copy or the client copy? Is the mOpen variable ghosted to the client? Does the door animate by playing an animation or by procedurally rotating the shape? Try checking the variable in processTick() instead.
#2
12/15/2007 (12:48 pm)
Hi Brian,

Thanks, though I think I've just figured something out with the packUpdate and unpackUpdate, being that they're only called when an object is created and not constantly throughout. Need to go over my TGE networking.
#3
12/15/2007 (1:07 pm)
Hmm, so the mOpen function is only being updated at startup because packUpdate and unpackUpdate only runs at startup. How can I then update mOpen variable during runtime then? The object is not a control object so I cannot use writePacketUpdate.
#4
12/15/2007 (1:55 pm)
You need to set a mask bit.

In your object's header create a new bit like this (assuming you dont have any existing mask bits)
enum MaskBits {
		OpenMask       = Parent::NextFreeMask,
		NextFreeMask   = Parent::NextFreeMask << 1
	};

Then whenever mOpen changes call:
setMaskBits(OpenMask);

For simplicity this is all you need. However to be more robust we usually check if the mask bit is set before sending extensive information. You should only be sending one bit though.
#5
12/15/2007 (6:30 pm)
Hi Brian, Was out for the day, implemented what you suggested when I got home. Great and thanks for the help, really going to help in the long run.