Erasing Objects

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Mercator
Posts: 16
Joined: Fri Jan 27, 2006 4:31 pm

Erasing Objects

Post by Mercator »

I want to create a shooter. In a class named "CProjectile" a bullet is loaded in this way:

Code: Select all

IAnimatedMesh* mesh;
IAnimatedMeshSceneNode* meshnode;
bool LoadMesh(char* filename)
{
   mesh = SceneManager->getMesh(filename);
   meshnode = SceneManager->addAnimatedMeshSceneNode(mesh);
   if (mesh && meshnode)
    return true;
   return false;
 }
The bullet is fired from the camera into the 3d space.
I wrote something like this to destroy the bullet:

Code: Select all

mesh=0;
meshnode=0;
mesh = SceneManager->getMesh(filename);
meshnode = SceneManager->addAnimatedMeshSceneNode(mesh);
When I run the code another bullet is fired and the old one remains on its last position. How can I destroy the bullet?
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

what i'm doing...
when the user pulls the trigger, i check to see if the bullet hits the terrain or floor. if it doesn't, I use a DeletionAnimator to make it remove its self after the maximum time, if it does, i work out when it should die
each frame, i move the bullet along, and if it hits something I use smgr->addToDeletionQueue to drop the bullet object.
hope this helps
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Mercator
Posts: 16
Joined: Fri Jan 27, 2006 4:31 pm

Post by Mercator »

Thanks, it works. :mrgreen:
Post Reply