Change camera culling mask?

I have a camera (the default) that renders everything. I want that if a player presses “space” and he has a specific skill, the camera disables rendering of everything except the terrain and some other objects, for 3 seconds. These other objects need to appear on the default layer too, they are just shown alone if space is pressed.

How would I go about JS’ing this?

You put the stuff you want to see all the time and the stuff you want hidden on different layers. Then you set the culling mask for the camera appropriately:

#pragma strict

var everythingCullingMask : LayerMask = -1;
var someStuffCullingMask : LayerMask = (1 << 8);


function Update() {
  if (Input.GetKeyDown(KeyCode.Space)) {
	  	Camera.main.cullingMask = someStuffCullingMask;
	  	Invoke("BackOn", 3.0f);
  }
}

function BackOn() {
	Camera.main.cullingMask = everythingCullingMask;
}