- Home /
Dynamically changing layers doesn't work for Camera.
I am currently dynamically changing a layer of my weapon to 11 when I pick it up, which is NoClip. I have set up my cameras so that one only renders the weapon and the other renders everything else. The weapon rendering one is layered on top. This works as long as I have a gameObject set manually, without script, to the NoClip layer. But as I switch the layer by script, by the following line,
gameObject.layer = 11;
The layer DOES change if I pause the game and check the inspector for the weapon, but the camera does not seem to update and the weapon is still shown on the camera that cannot see the NoClip layer and not shown on the camera that is supposed to see the NoClip layer.
Answer by william9518 · Oct 12, 2013 at 08:45 PM
I am so stupid. I had to change the layer of all the children of my gun.
Your answer
Follow this Question
Related Questions
HDRP Camera weapon layer 1 Answer
Multi camera lighting for object with layer no selected 0 Answers
Render GameObjects over GUI.Layer 1 Answer
Unity3D scene not rendering objects in Game screen 3 Answers