What does "<<" mean?

I saw this in someone’s code, here was the variable declaration with this in it:

private int groundMask = 1 << 8;

It was called later in a raycast2d if statement.

if (Physics2D.Raycast(new Vector2(_transform.position.x-0.1f,_transform.position.y), -Vector2.up, .26f, groundMask) 
		    || Physics2D.Raycast(new Vector2(_transform.position.x+0.1f,_transform.position.y), -Vector2.up, .26f, groundMask))
			grounded = true;
			jumps = 0;
			grounded = false;
			_rigidbody.AddForce(-Vector3.up * fallVel);

So what is it? What does it mean/do?

It’s used to shift 8 bits left.

It’s used here to only raycast on the 8th layer (which should be set in the editor).

You can setup layers to the objects in your hierarchy (see layers in the inspectors). The editor allows you to edit layers :


for further info, see Unity - Manual: Layers