- Home /
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?
Answer by robertbu · Mar 07, 2013 at 02:41 AM
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;
}
Indeed! I did so accidentally too, before I saw your answer. Thanks :D
Your answer
Follow this Question
Related Questions
Camera Culling Mask not working as expected? 1 Answer
Render an layer from the position of player to a specific distance 0 Answers
Camera rendering things it shouldn't 0 Answers
Ignore Collisions 1 Answer
quad meshes on camera layer (hud) 1 Answer