- Home /
Turn Off/on culling mask by script?
Hi, i am making a script that change my camera from First Person to 3rd person view, when i use First Person i have disabled the player model culling mask so it doesn´t intercept. But when i switch to 3rd person view i want to disable that specific Culling mask that hides my player model. How do i turn it off at runtime by using script?
Answer by SilverTabby · Aug 07, 2011 at 11:14 AM
The easiest and most modular way to do this is by simply creating two LayerMask variables and switch between them as needed using Camera.cullingMask.
var firstPersonCullingMask : LayerMask;
var thirdPersonCullingMask : LayerMask;
When you switch to first person, Camera.main.cullingMask = firstPersonCullingMask.value;
And when you switch to third person, Camera.main.cullingMask = thirdPersonCullingMask.value;
You can also disable the individual layers by hand if you know how to work with the computer's base 1s and 0s, but it's simply easier to just store two vars.