OverlapSphere ignoring all colliders when I use the layerMask parameter.

When I try to use the layerMask argument it ignores all layers and doesn’t detect any colliders and/or objects. In all the examples I’ve seen people usually assign an integer the number of the layer and then use it as the right operand of a left bit shift operator on 1, for example: 1 << iLayer. I don’t understand why they do this, there isn’t very good documentation on this function or that argument in particular and even after doing the left bit shift it still ignores all colliders/objects in the scene if I try to use the layerMask parameter. Same if I just put the integer only or try to use the LayerMask.NameToLayer method. Any suggestions, explanations, documentation, examples, etc would be much appreciated as to why it isn’t working and how to properly use this function and or parameter.

using UnityEngine;
using System.Collections;

public class SunGrav : MonoBehaviour {

	private Collider[] hitColliders;

	void Update () {
		hitColliders = Physics.OverlapSphere (transform.position, 20.0f, 8);
		for (int i = 0; i < hitColliders.Length; i++) {
			Debug.Log (hitColliders *);*

_ hitColliders .gameObject.SetActive (false);_
* }*
* }*
}

A Layermask is a bitmask. An integer has 32 bits and so in bit form it can represent the on-off state of 32 channels!

The bit shift operator is setting up this mask by taking number 1 (00000000000000000000000000000001 - binary) and shifting (rotating around) the number effectively moving the number 1 to the left (00000000000000000000000010000000 - binary).

Try

int layerMask = 1 << 8; //Layer 8
hitColliders = Physics.OverlapSphere (transform.position, 20.0f, layerMask);