Hi,
I need an object to collide ONLY with objects in a specific layer.
looking the Physics.IgnoreCollision I should be able to do it using
Physics.IgnoreLayerCollision(1<<gameObject.layer, (0xFFFFFFFF (~(1<<target_game_object.layer))), true);
but this gives me an error in the console saying that it cannot convert a long into an int on the second parameter O_o
i’m quite sure “8” F means 32 bits, anyway… it could be because the first 8 bits are reserved by unity so i thought using 0xFFFFFF instead (removing “two F”) should do the trick and in that case it compiles but when it try to execute it gives me another error
“layer numbers must be between 0 and 32”
That basically means that in this case layer do not work as a bit mask but the function wants the actual layer number… and anyway shouldn’t the error say “between 0 and 31”?
An easy way is doing what i need would be something like
int my_layer = gameObject.layer;
for (int layer=31; layer>=0; layer--)
{
Physics.IgnoreLayerCollision(my_layer, layer, true);
}
Physics.IgnoreLayerCollision(my_layer, target_game_object.layer, false);
but i really hope there’s a cleaner way to achieve it
Any thoughts/helps will be appreciated.
Thanks,
A