It is not clear in the documentation: If a ray cast is sent from 2 different objects who will receive the hit message? Because it seems to me that a ray casting from one object is being detected by another object.
Yes, this is a perfect example of the kind of problems you may run into with global functions. You should use local functions at all times to avoid this and similar problems.