I thought it might be a message order or calculation order problem so I cleaned up your patch for you, but the problem is still there... I suspect it's a 3d spatial calculation issue, which i know nothing about...
but anyway, the clean-up has made the patch a lot more efficient, and the message order is now explicit, using the trigger object-- also note use of vexpr
EDIT: reposted patch (forgot to delete a redundant object)