Switching Weapons!
Posted: Wed Apr 19, 2006 3:05 pm
I want to incorporate more weapons in a FPS game and have made it switch weapons from a uzi to a shotgun. But have one problem, when the switch occurs the games slows down.
I believe it is because the previous weapon mesh has not been cleared from the memory or something!?! Is there any way to delete the addAnimatedMeshSceneNode? or is there another of switching weapons?
I would appreciate any help on this issue.
thx
This is the coding so far:
I believe it is because the previous weapon mesh has not been cleared from the memory or something!?! Is there any way to delete the addAnimatedMeshSceneNode? or is there another of switching weapons?
I would appreciate any help on this issue.
thx
This is the coding so far:
Code: Select all
irr::scene::IAnimatedMesh* m_pWeaponMesh;
irr::scene::IAnimatedMeshSceneNode* m_pWeaponNode;
if(weapon==1)
{
m_pWeaponMesh = pManager->getSceneManager()->getMesh("media/uzi.3ds");
//m_pWeaponNode = pManager->getSceneManager()->createDeleteAnimator();
}
else if(weapon==2)
{
m_pWeaponMesh = pManager->getSceneManager()->getMesh("media/mygun.3ds");
}
m_pWeaponNode = pManager->getSceneManager()->addAnimatedMeshSceneNode( m_pWeaponMesh, pManager->getSceneManager()->getActiveCamera(), -1);
m_pWeaponNode->setMaterialFlag(video::EMF_LIGHTING, false);
m_pWeaponNode->setMaterialTexture(0, pManager->getDriver()->getTexture("media/uzi.jpg"));
m_pWeaponNode->setScale(core::vector3df(2,2,2));
m_pWeaponNode->setPosition(core::vector3df(12, -8, 25));
m_pWeaponNode->setRotation(core::vector3df(-2,0,0));