Collision Problem (764725)

So, im trying to build a bomberman game from zero to practice and get familiarized with unity, i have walls which are indestructible and boxes which bombs can destroy. When a bomb explodes it creates explosions around it where theres no walls.

Im doing this, but for some reason its detecting collision with layers that are not “blockingLayer”.

Edit: so i discovered that this collision was working actually, but the explosion was being instantiated under the box, therefore i couldnt see it.

But now theres a new problem, the explosion is instantiated on the same position as the box, how do i detect this collision? i was trying to do this, but it doesnt seem to work:

maybe blockingLayer is an integer index instead of a layer mask can someone explain him how to convert? Don’t remember right now its something like 0x01 << blockingLayer

edit:
try ((int) 0x01 << blockingLayer) in the linecast method not sure if that’s correct but should solve it
edit2:

linecast(…,((int) 0x01 << blockingLayer) );

Not sure, but I find the easiest thing to do is just declare a public LayerMask member variable, then you can just select which layers I want in the inspector.

Use the LayerMask variable as a parameter in the LineCast method, and the implicit cast from LayerMask to int will automatically get you the correct value.

nice didn’t know that.

So he had to use LayerMask instead of an int value, if we assume blockingLayer is a plain int

I think im already doing that:

5150105--510113--upload_2019-11-7_13-22-40.png

Well, the parameter is an int value either way. I was just suggesting to use the LayerMask because that will automatically give you the correct value, rather than having to figure it out yourself. You don’t have to use a LayerMask- it’s just a matter of convenience.

Not sure why it’s not working, then. Have you used debug.log to find out what the line cast is actually hitting?

Kinda, what exactly should i watch while debugging?

The name and layer of the object? Just so you know for sure that what your LineCast is hitting is what you think it’s hitting.