How to make things appear when

How to make an object/sprite appear when 3D object passes under/over/into another object a certain number of times