Nice work. I tried counting with one laser by remembering the last entityID hit and only increment the hit count if there is a new entity. That failed when two balls rolling by were touching each other. I then tried only counting if the other entityID did not match either of the last two entities hit. This didn't work about 1% of the time and would never work if there were only two balls. I then tried putting in a delay between hit checks and that didn't work. So I like your approach a can't think of any better way. The only suggestion I would make is to put the laser counter and the collision counter on the same slide and put the counter displays side by side.
Suggestions:
1. Put all the balls to the left of both counters at the start.
2. Set maxRays = 1 for both lasers (or else you may get ~1% counting errors).
The following code worked for me with just one laser:
_eID := 0;
onLaserHit := (e)=>{
eID := e.geom.entityID;
eID != _eID ? {
my.scene.hits2 = my.scene.hits2 + 1;
_eID = eID
} : {}
};
maxRays := 1;