Topic: count the collisions number of an entity (c++)

Hi, i try to count the number of meshs which are in collision with an ghost entity, but maratis crash ... this is the code I use :

MEngine * engine = MEngine::getInstance();
        MyGame * game = (MyGame*) engine->getGame();
        MLevel* lvl = engine->getLevel();
        MScene* scene = lvl->getCurrentScene();

        unsigned int Id;
                int nbColl;
        MOEntity* ent= scene->getEntityByName("myEntity");
        scene->getObjectIndex(ent->getName(), &Id);
        MPhysicsContext * physCont = engine->getPhysicsContext();

        nbColl = physCont->isObjectInCollision (Id);
// here maratis crash

Last edited by Alinor (2011-12-03 19:41:59)

Re: count the collisions number of an entity (c++)

Hi,
the id is not the object id but the collision id,
you can get it using "entity->getPhysicsProperties();" (it is NULL if the object doesn't have physics enabled)

MPhysicsProperties * phyProps = ent->getPhysicsProperties();
if(phyProps)
    nbColl = physCont->isObjectInCollision(phyProps->getCollisionObjectId());

Re: count the collisions number of an entity (c++)

thanks Anael for these precisions wink

Re: count the collisions number of an entity (c++)

you're welcome smile