Alright, I'm out of ideas right now. I came up with something which should work, cause it works in the ProjectX by TBJokers and I can't figure out why it doesn't work for me...
This is defined in the monster structure:
Code:
void MOB::spawn(Str obj, Vec pos)
{
Game::ObjParams obje; obje.load(obj);
super::create(obje);
Flt y = Game::World.hmHeight(pos.xz(),true);
T.pos(pos+Vec(0,y,0));
ctrl.actor.group(false);
}
Bool MOB::update()
{
if(super::update())
{
return true;
}
return false;
}
and this is in the game file:
Code:
Memc<MOB> Monsters;
[i]/* the following code part is in the update loop */[/i]
if(Kb.bp(KB_SPACE)) Monsters.New().spawn("obj/chr/skeleton/0.obj", Vec(0,0,0));
FREPAO(Monsters) .update(); // update all mobs
I have no idea why the monster is not spawning in the actual game... Any ideas?
EDIT: Btw, I've also tried this method:
Code:
Game::ObjParamsPtr obj = Game::Objs.ptrRequire("obj/chr/skeleton/0.obj");
Game::World.objCreate(*obj, Matrix(obj->scale(), Vec(0,0,0)));
which is shown in
Game Basics Tutorials #10 - Dynamically Created Objects and it doesn't work either.