GameConnection:setControlObject
by William Todd Scott · in Torque Game Engine · 11/15/2005 (8:07 pm) · 3 replies
This may be my lack of understanding, but...
In GameConnection::setControlObject() there is the following test
// Nothing else is permitted to control this object.
if (ShapeBase* coo = obj->getControllingObject())
coo->set ControlObject(0);
Shouldn't that be coo->setControllingObject(0)
If not, can someone explain why we are checking the controlling object and then setting the control object?
Thanks
Todd
In GameConnection::setControlObject() there is the following test
// Nothing else is permitted to control this object.
if (ShapeBase* coo = obj->getControllingObject())
coo->set ControlObject(0);
Shouldn't that be coo->setControllingObject(0)
If not, can someone explain why we are checking the controlling object and then setting the control object?
Thanks
Todd
#2
Because we're clearing the control object of the object currently controlling the object we wish to control. (That makes it clear as mud, yes? :P )
We want exclusive control over object "obj". So we ask obj for the object (if any) that is currently controlling it ("obj->getControllingObject()"). If there is such an object, then a pointer to that object is returned, and coo becomes that pointer. So "coo" is "the object controlling obj". Of course, "obj" is the object we want to control. We can't have coo also controlling obj, so we tell coo that it should control nothing ("coo->setControlObject(0)").
At least, that's my understanding of that particular block of code.
11/17/2005 (12:32 am)
RE: "can someone explain why we are checking the controlling object and then setting the control object?"Because we're clearing the control object of the object currently controlling the object we wish to control. (That makes it clear as mud, yes? :P )
We want exclusive control over object "obj". So we ask obj for the object (if any) that is currently controlling it ("obj->getControllingObject()"). If there is such an object, then a pointer to that object is returned, and coo becomes that pointer. So "coo" is "the object controlling obj". Of course, "obj" is the object we want to control. We can't have coo also controlling obj, so we tell coo that it should control nothing ("coo->setControlObject(0)").
At least, that's my understanding of that particular block of code.
#3
I started going cross-eye by the time I got to that point...I should've just gone to bed!
Thanks for the help.
Todd
11/17/2005 (11:41 am)
Yep, that seems right.I started going cross-eye by the time I got to that point...I should've just gone to bed!
Thanks for the help.
Todd
Associate Kyle Carter