Game Development Community

Problem adding sceneobject via c

by Wesley Hopson · in Torque Game Engine · 12/08/2008 (5:02 pm) · 0 replies

Thanks to Nathan i found some information on what to do to add a object via c++. For my case i am using 2 very stripped down classes which are little more than templates of a scene object. One object Gridpoly has a pointer to another polynode so I want to create one polynode whenever a gridpoly is added to the scene. While i am glad it does indeed work and add both objects to the scene and they render what not. The problem is it is also adding 2 polynode's instead of just the one i want.

Quote:bool GridPoly::onAdd()
{
if (!Parent::onAdd())
return false;

node = new PolyNode();
node->setPosition(this->getPosition());
node->registerObject();
addToScene();

return true;
}

That is the on add snipet i am using. I am still pretty new to this if thier is some pieces of code else where that need to be put in somewhere else to make this work. Just getting me pointed in the right direction would help alot.