running command on entry to a bounding box
Hey guys,
Ok I have a cylinder moving around a scene, what I would like to do is run a command when the cylinder enters within the bounding box of a stationary cube and when it leaves.
Below is the expression I have so far, it gets the bounding box of each item and prints a word when it is within the same bounding box, at the moment it is only for the worldspace in X.
The problem is, it keeps printing the word when its inside the bounding box rather than just once on entry, any ideaas on how to get this to work?
//////////////////////
float $cylBBox[] = `xform -q -ws -boundingBox pCylinder1`;
float $cubeBBox[] = `xform -q -ws -boundingBox pCube1`;
if ( ($cylBBox[0] < $cubeBBox[0]) && ($cylBBox[3] < $cubeBBox[3]) )
{
print "whatever";
}
/////////////////////
Many thanks
Chris