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:
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.
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.