Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I wouldn't use classes, I would use interfaces for this. And I would only have it so when the collision is triggered it checks the parent hierarchy for anything with an interface you defined. Either way both mine and Alex M's method will work.