animate visibility

Hey, I'm pretty new to Unity but am picking it up very quickly. This should be a simple answer but I'm not sure how to do it and couldn't find any help on the web or the resources. I have objects shoot and then disappear (destroy) after a couple seconds so my computer won't die after so many objects being shot. I wanted to know if there was a way to make them fade away after a couple seconds instead of just abruptly disappear. I thought about using a color change like color.lerp(activeMaterial, color.clear, time.time) but I'm not sure how I would write that code. Any help would rule! Thanks :)

See this page for hints:

So it might look something like this:

// Fade the color out

var duration : float = 1.0; private var lastTime = 0;

function Update () { if ((Time.time - lastTime) < duration) renderer.material.color.a = (Time.time - lastTime) / duration; lastTime = Time.time }

Anyway, not tested, but that should get you started. Probably a more efficient way to be found.


right now i’m working on an app using the Vuforia AR SDK. I have to animate the visibility of models because i have one model for every frame. Just like you would get from a fluid animation you import from Realflow. It works nicely in Maya and Cinema 4d but Unity won’t read the visibility i adjusted in other 3d-software. So i will have to do it in Unity3d. I’m not much of a coder though but i guess one could write an easy script for it. I even would do it manually once, to check out if it runs on an android. Do you have any ideas how i could solve this? this ist my project. All models “frames” are visible at the same time so it looks like a strange polygon mayhem. The meshes in the parent directory “test 2 von f 0” on the left side > ofmensh, ofmesh1, ofmesh2… should be just visible in one frame according to their name. Can someone help me?

Thanks in advance for your help.

Greetings from Germany,