I have an array of some colliders and I’m checking with a Physics.Linecast if there is an object betwen my object in my array and my position. Now I want that the Linecast ignore only one specific collider in the world. This should be accomplished without using labels and layers.
u could use a RaycastAll, get all the results then compare them to the object u want to omit, thus giving you the same result. (you can define a distance in the ray of RaycastAll causing it to be a LineCastAll)
Why? This is sort of what layers were designed for. It doesn’t matter if it’s one object or one-thousand objects. Use a layer mask to cull the collision test.
There’s no reason not to use this feature (that I can think of). Layer masks are practically free (computationally speaking; it’s probably no more than a single logical-and operation and a compare operation per object). And it’s almost always going to be faster to cull expensive ray intersection tests with a layer mask, compared to testing the raycast against all potential colliders in the scene and then filtering the results post hoc.
The problem with the Layers is, that I already use a LayerMask on the Objects which I want ot check and I would have to change the LayerMask on the Object wich should be ignored. The problem there is, that probably multible scripts are accesing to this Object and if the Layer is changed they won’t work correctly.
Anyways I’ve done it with Layers. Because I don’t wanna callculate the Raycasts and it’s then much easier for me. The problem with accesing is not so big.
But I have now an other problem at this point. The Layer won’t change.