Still haven't been able to figure it out. I added the destructor since I didn't have it before, but the enemy models still go to their destination and just stay there forever.
enemy.cpp
Code: Select all
#include "enemy.h"
irr::scene::IAnimatedMeshSceneNode* mob;
enemy::enemy()
{
}
enemy::~enemy()
{
mob->remove();
}
void enemy::killHumansKThx(irr::video::IVideoDriver* driver, irr::scene::ISceneManager* smgr, int speed, bool repeat, int initX, int initZ, int finalX, int finalZ)
{
mob = smgr->addAnimatedMeshSceneNode(smgr->getMesh("media/hydralisk/tris.md2"));
if (mob)
{
irr::scene::ISceneNodeAnimator* anim1 = smgr->createFlyStraightAnimator(
irr::core::vector3df(initX, -65, initZ),
irr::core::vector3df(finalX, -65, finalZ),
speed, repeat);
if (anim1)
{
mob->addAnimator(anim1);
anim1->drop();
}
mob->setMaterialFlag(irr::video::EMF_LIGHTING, false);
mob->setMD2Animation(irr::scene::EMAT_RUN);
mob->setScale(irr::core::vector3df(2.5f, 2.5f, 2.5f));
mob->setMaterialTexture(0, driver->getTexture("media/hydralisk/lisc.pcx"));
}
}
main.cpp
Code: Select all
void createZombies (irr::scene::ICameraSceneNode* player, irr::video::IVideoDriver* driver, irr::scene::ISceneManager* smgr)
{
for (Iter = waypointSystem.begin(); Iter != waypointSystem.end(); Iter++)
{
twovar origin = (*Iter).first;
std::vector<twovar> destination = (*Iter).second;
std::vector<twovar>::iterator secondIter;
for (secondIter = destination.begin(); secondIter != destination.end(); secondIter++)
{
zombie.killHumansKThx(driver, smgr, 3000, false, origin.getX(), origin.getZ(), (int) player->getPosition().X, (int) player->getPosition().Z);
zombie.setRotation(irr::core::vector3df(0,directionSolver(origin.getX(), origin.getZ(), secondIter->getX(), secondIter->getZ()),0));
}
}
}
I left out a lot of unneccessary code, so the variables that might seem undefined, are defined and working properly.