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.
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.
About the author
www.atomicbanzai.com
#2
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.
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
In your object's header create a new bit like this (assuming you dont have any existing mask bits)
Then whenever mOpen changes call:
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.
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.
Torque Owner Michael Bacon