View Full Version : setting overlayEntity position in realtime problem

08-08-2011, 11:50 AM
Hello. I use proton & irrlicht to work on a mini game. I was sitting 2 days debugging my app because I thought I have an irrlicht problem. But I discovered that something is wrong with my overlayEntity. It looks like this: I have an array list of MeshSceneNodes. In each iteration of main loop I get their 2D position from 3D position. If the 2d position of one of those nodes is in a defined rectangle in the middle of the screen I would like to set that overlayEntity position to that node 2d position. I've been debugging the app and it definietly catches the moment when a node is targeted... but... it changes the overlay positiononly for one node! Why is this happening? The Code looks like this:

void DrawPigLifesStat()
int scX = (int)(GetScreenSizeX()/2.0f);
int scY = (int)(GetScreenSizeY()/2.0f);

for(int i = 0; i < number_of_pigs; ++i)
pigPosXY[i].X = GetIrrlichtManager()->GetScene()->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(pig[i]->getPosition(),GetIrrlichtManager()->GetScene()->getActiveCamera()).X;
pigPosXY[i].Y = GetIrrlichtManager()->GetScene()->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(pig[i]->getPosition(),GetIrrlichtManager()->GetScene()->getActiveCamera()).Y;

if( ( pigPosXY[i].X >= (scX-64) ) &&
( pigPosXY[i].X <= (scX+64) ) &&
( pigPosXY[i].Y >= (scY-64) ) &&
( pigPosXY[i].Y <= (scY+64) )
LogMsg("Pig #%d Targeted! ",i);
GetMessageManager()->SetEntityVariable(pigHeart, 0, "pos2d", CL_Vec2f(pigPosXY[i].X ,pigPosXY[i].Y));

GetMessageManager()->SetEntityVariable(pigHeart, 0, "pos2d", CL_Vec2f(0,0));


That log message shows that all of me nodes are beeing targeted correctly... But why does the overlay change its position only for one node?