Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MEngine * engine = MEngine::getInstance();
- MGame * game = engine->getGame();
- // check if the game is running, removing thif test will enable In-Editor update (like for the lookAt behavior)
- if(! game->isRunning())
- return;
- unsigned int objid=0,playerid=0;
- // get the associated parent object (who is using this behavior)
- MObject3d * parent = getParentObject();
- // get the actual scene
- MScene* nScene=engine->getLevel()->getCurrentScene();
- // get from the actual scene the object Index to be used for function isObjectsCollision in MPhysicsContext
- nScene->getObjectIndex("select", &playerid);
- nScene->getObjectIndex(parent->getName(), &objid);
- MObject3d * behaviorObj=nScene->getObjectByIndex(objid);
- MObject3d * playerObj=nScene->getObjectByIndex(playerid);
- if((behaviorObj->getType() == M_OBJECT3D_ENTITY) && (playerObj->getType() == M_OBJECT3D_ENTITY))
- {
- MOEntity * entity1 = (MOEntity*)behaviorObj;
- MOEntity * entity2 = (MOEntity*)playerObj;
- MPhysicsProperties * phyProps1 = entity1->getPhysicsProperties();
- MPhysicsProperties * phyProps2 = entity2->getPhysicsProperties();
- if(phyProps1 && phyProps2)
- {
- MPhysicsContext * physics = MEngine::getInstance()->getPhysicsContext();
- int collision = physics->isObjectsCollision(
- phyProps1->getCollisionObjectId(),
- phyProps2->getCollisionObjectId()
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement