- Home /
Fade 2 out of 3 gameobjects on the screen who have the same material
I have a sequence where I have three instanced characters on the screen that use the same material. I want to select one and have the other two slowly fade out. At the moment I can only seem to fade the material and it will fade all three gameObjects, but I want one to stay visible. Is there any way to do this?
Thank you.
Answer by tanoshimi · Jun 11, 2016 at 05:27 PM
Make sure you fade the material, not the sharedMaterial, and you should get the behaviour you want.
Ah! You are correct! Thank you. I was playing with the material outwith the game code to see what might work. I delved a bit deeper with your material vs shared$$anonymous$$aterial and found out that this code treats the material a copy in unity when called upon.
this.gameObject.GetComponent.().material.color.a = 0;
Thank you, sometimes just need a nudge in the right direction.
Answer by jsra15 · Jun 11, 2016 at 07:10 PM
If you want to change the material of a GameObject, you can use an animation, with this when you select a mesh and want change the material, be amended nothing more material the mesh you selected and not the other objects with the same material. You could do this with the " Animator" window (If you know , of course) . In this way we can control the time when the animation begins, stop , etc ...
Another option would be from a script. To do this if you use C # you would have to create two variables , one finds the "MeshRenderer" of the object, and one that finds the material (I think this is not very useful in your case, this method modifies the material and therefore all objects in attachment to this material ) .
The most useful option in your case would be an animation . I hope you will be useful and it worked
Your answer
Follow this Question
Related Questions
Shader that makes object transparent as light hits it 0 Answers
Fading a GameObject in/out 1 Answer
Make a gameobject with textures semitransparent 3 Answers
How to add a FADE effect only on a side of a model? 0 Answers
appear/disappear gameobject 3 Answers