Page 2 of 2

Posted: Wed May 30, 2007 7:14 am
by vitek
Yeah, it should be linear_reverse_search. As for where 'node' came from, it is the node that you are about to remove from the scene. It could come from anywhere.

As I said before, unless you have a really good reason to maintain an external array of scene nodes, it should be avoided. Why do you think that you need the external array?

Travis

Posted: Wed May 30, 2007 7:41 am
by kennypu666
i was going to use an array for example the enemys in a fps, so i dont have to make each one seperatly. at the moment i dont really need an array because im stlil trying to figure out how to check if the bullet collided, how to delete them,etc. but yea thats about it.

Posted: Wed May 30, 2007 8:50 am
by vitek
Ah, sorry I lost track of which post was which. Yes, it makes sense to use an array for bullets and for enemies. If you had an array of bullets that would go away after some preset time interval, you wouldn't need to search for which bullet to remove. You would probably have a function to walk over the bullets and see if any of them passed through a bad guy since the last time you checked. If your bullets could 'expire', you'd check to see if each had expired, and if it had you'd remove it from the scene and from the array.

Travis

Posted: Thu May 31, 2007 1:27 am
by kennypu666
yea, I have a thing for the bullets alread. its not an array though. I still have a question about making the array because I dont know how to do it. I tried a way and no errors but the program crashed so i guess i did it wrong. I still dont understand how the "node" came from. this is what i did.

Code: Select all

    core::array<scene::ISceneNode*> SceneNodes; //da array for enemy(boxes)
    //create a node and add it to the array
    SceneNodes.push_back(smgr->addCubeSceneNode(100.0f));
    scene::ISceneNode* bnode = SceneNodes[0];
and this is the part where i use node->remove();

Code: Select all

            s32 found = SceneNodes.linear_reverse_search(bnode);
                    if (found != -1)
                       SceneNodes.erase(found);
                    bnode->remove();
srry for being so stupid.

Posted: Thu May 31, 2007 3:38 am
by BlindSide
Have you tried "addToDeletionQueue" Instead of remove? Its supposed to wait till the node is free before trying to remove it.

Posted: Thu May 31, 2007 4:50 am
by kennypu666
thanks for the idea, but it still crashed. I just think that i specified bnode wrong. anybody know how to set a node the right way? sorry lol.