Noob here, cribbing from other scripts, I see that I can do...
target.renderer.material.color.a -= Time.deltaTime/fadeDuration;
to fade out an object. And, elsewhere in the docs, I see that EVERYTHING YOU SEE ON SCREEN has a renderer that you can enable = true/false to show/hide it. Ok... but the above line gives me "renderer is not a component of GameObject" error. So, being resourceful, I think...
var target : GameObject;
var targetRenderer : Renderer;
function Start()
{
targetRenderer = target.GetComponent(Renderer);
if (targetRenderer == null)
targetRenderer = target.GetComponentInChildren(Renderer);
}
function Update()
{
if (targetRenderer.material.color.a > 0)
targetRenderer.material.color.a -= Time.deltaTime/fadeDuration;
}
but then I get "trying to access Renderer on GameObject when there is none." What gives? What am I missing?! If it's on-screen, it's got to have a renderer, right?!
Thanks!
P.S. All I really want to do is make my object fade out before removing him from the scene, like in TonyD's script, here.