xzessmedia
Member
|
Getting Obj from World Manager
Hello again,
im trying to use Game::World.objGet to check for objects in range.
Code:
Memp<GameObject*> objs;
..
..
..
Game::World.objGet(objs,Ball(radius, T.pos()));
can anybody explain me how the Memp init works?
thanks in advice
|
|
02-15-2014 07:43 PM |
|
Esenthel
Administrator
|
RE: Getting Obj from World Manager
|
|
02-15-2014 10:37 PM |
|
xzessmedia
Member
|
RE: Getting Obj from World Manager
thanks greg
I get it working but i am only able to get Game.Obj types.
i want to get my subclass from Game.Obj cause it has actor and so on..
are there more ways?
what would be the best way in performance to iterate through objects?
|
|
02-16-2014 09:09 AM |
|
Esenthel
Administrator
|
RE: Getting Obj from World Manager
You can use dynamic_cast (like the CAST macro).
That's also covered in the Bloody Massacre tut:
Code:
void autoPickUp() // automatically pick up nearby items
{
Memt<Game.Obj*> obj;
Vec test_pos=ctrl.center()-Vec(0, ctrl.height()/2, 0);
Game.World.objGet(obj, Ball(2, test_pos), OBJ_ITEM);
REPA(obj)
if(Item *item=CAST(Item, obj[i]))
if(item.type==ITEM_WEAPON && item.mesh && Dist(test_pos, item.mesh->box*item.matrixScaled())<=ctrl.radius()+0.1f)
{
AddMessage(S+"Picked up "+item.name);
itemPickUp(*item);
}
}
|
|
02-16-2014 09:12 AM |
|
xzessmedia
Member
|
RE: Getting Obj from World Manager
ah im sorry to forgot to read it again as you mentioned.
thank you very much this helped!
|
|
02-16-2014 09:42 AM |
|