- Home /
With multiples cameras, How to change what is rendered without using layers?
When having multiples cameras, I know It is possible to choose which layer each camera renders. However, I'd like a camera to render a specific gameobject without using layers for two reasons :
I want to change which object is rendered at runtime, so it might be one instance of a prefab that appears multiple times.
I'm already using layers for other purposes right now. So If I wanted to use layers, I couldn't just make one layer being rendered by the first camera and I'd have to make a double for each layer I currently have.
Answer by nesis · May 25, 2014 at 06:48 PM
Sounds like you just need to put your mesh on one layer and your collider on another. Decouple them by putting them on separate GameObjects, one parented to the other, or both parented to some other GameObject.
I could see that working. I'm gonna wait to see if someone has a better solution because it's gonna take some work since I didnt do this from the very start.
Alright, Although this doesn't really answer the question, it is a workaround so I will put it as answered for the time being.
Answer by Jeff-Kesselman · May 25, 2014 at 06:34 PM
1 is easily fixed as you can reset the layer at run time within a script.
As for 2, you don't say what "other purposes" you are using layers for bit if its for anything other then controlling render or ray cast hit, its probably wrong.
its true that number 1 isnt much of an issue without problem 2.
I'm using the layers to ignore different raycasts I do. Like I said, I can just make new layers that will also have the same proprieties as the one before except that they'd be rendered on another camera. However, It seems more like a temporary fix than a good way to do it.