- Home /
Controlling an object's transparancy on trigger
In my game, I want my room prefab to turn at least somewhat transparent or even invisible after a condition concerning an object within it is met, after which it instantiates another room.
I have all my instantiation code working, it's just the transparency that I don't understand. I want to make the previous room transparent so it doesn't get in the way. I don't know exactly how to control this and I keep reading it depends on the material being used. Right now, I'm using a Toon/Lighted material for most of my models. I'm not sure if that material has an alpha channel within it or not. Exactly how would I control the transparency of my overall prefab or individual models within it, preferably the former since doing it one by one may be somewhat time consuming.
Hi! You need to have a $$anonymous$$aterial that has an alpha property on it. Before trying to do the transparent stuff in code, try it in the inspector using different materials and shaders.
Answer by ZDS Alpha · Nov 06, 2013 at 11:28 AM
Create such a material:
Handle Transparency:
Handle Transparency using scripts:
gameObject.renderer.material.color.a = 0.5;
For more info: http://docs.unity3d.ru/Components/shader-TransDiffuse.html
Your answer
