Finally got a somewhat working collision detection system