Raycast Filter Mask not Working.

	void OnMouseDrag(){
		ray = _main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit, 100, -gameObject.layer)){
			target = _main.transform.InverseTransformPoint(hit.point);
		}

I want to exclude every layer that is not the same as the script holder from raycasting, so I used -gameObject.layer but the raycast seems to not exclude any layer exceptthe default layers (default, ignoreRaycast and transparentFX).
All my custom layers are treated like one and no filtering is done with them even if they are not the same as the object calling the raycast, What’s wrong help!!

layermasks are handle by bitmasks

the bitmask created by the notation 1<<10 means “only layer 10”

so because gameObject.layer returns the layer index (1 to 31), not a bitmask, you need to use
(1<<gameObject.layer)
for “only gameobject layer”
or
~(1<<gameObject.layer)
for “all layers execpt gameobject layer”

the Layers documentation page was missing from my build, I solved ir anyway with shift mask operator <<, thanks.