How to check the collision layer on collision event?

I’m sorry, I know this is basic stuff, but I can’t find up to date answers ANYWHERE!!! :stuck_out_tongue:

I have a collision event already set up, but it will fire for anything it collides with. I only want it to react to a specific collision layer. How do I do it?

Here’s an answer from 2012, but it doesn’t seem to work anymore: How to tell if my character hit a collider of a certain layer - Questions & Answers - Unity Discussions

There’s no reason it shouldn’t work - the Collider object still can access the GameObject it is attached to and in turn its layer:

void OnCollisionEnter(Collision collision) {

Check if you have your layer set up on the GameObject that contains the collider component. Maybe you’ve set up the layer on a parent object and not its children?