Set a flag for IF statement

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Set a flag for IF statement

Post by The_Glitch »

I'm not sure I set the best title for this topic. I have a sound I would like to play when the camera node is below a distance from another node. It works fine once but then doesn't work again.
So lets say the event happens when the camera is <= 10.0f from a node in the if statement it fires once, then the node moves away, later comes below the distance again but the event doesn't happen again.

Code: Select all

 
while (device->run())
    if (device->isWindowActive())
    {
 
 
f32 distance = node->getAbsolutePosition().getDistanceFrom(camera->getAbsolutePosition());
 
 
 
if( distance <= 10.0f)
{
 
   // sound plays here
}
else if ( distance >10.0f )
{
      /// nothing here yet trying to perfect this
}
 
 
}
 
Post Reply