- Home /
Traning Dummy Part Destructor
What is the point of this script?
What does the SkinnedMeshRenderer have to do with anything?
class TrainingDummyPartDestructor extends MonoBehaviour { private var alpha : float; private var timer : float; private var color : Color; private var r : SkinnedMeshRenderer; private var colorName : String;
function Start()
{
r = renderer;
if(r.material.HasProperty("_MainColor"))
{
colorName = "_MainColor";
}
else if(r.material.HasProperty("_Color"))
{
colorName = "_Color";
}
else
{
Destroy(gameObject);
return;
}
color = r.material.GetColor(colorName);
alpha = 1.0;
timer = 3.0;
}
function Update()
{
if(timer > 0.0)
{
timer -= Time.deltaTime;
}
else
{
if(alpha > 0.0)
{
alpha -= Time.deltaTime;
color.a = alpha;
r.material.SetColor(colorName, color);
}
else
{
Destroy(gameObject);
}
}
}
}
Answer by Dreamer · May 13, 2011 at 02:46 AM
What this script does:
Wait for 3 secs (timer variable)
Reduce alpha value over time until alpha becomes 0 (invisible)
Once alpha becomes 0, destroy this object.
A renderer is what makes an object appear on the screen.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133909im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Any chance to extract bootcamp model with some scripts? 1 Answer
Bootcamp About Menu Help 1 Answer
How to add a New BootCamp Soldier? 1 Answer
Car decals (bootcamp system modified) 1 Answer
Unity Test shows black screen 7 Answers