hiya,
Do you have some time to help me on this, please?
I have a particle system shooting at a sphere which I want to light up when particles collide.
Right now I have two scripts:
1 - one called “Color Change”, that just swaps the sphere’s material.
2 - and another called “Trigger” that is supposed to listen for particles that collide, enable “Color Change” during some time, and then disabling it.
I can’t get it to disable the “Color Change” script.
1 - “Color Change” :
var material1 : Material;
var material2 : Material;
function Update () {
renderer.material.Lerp (material1, material2, 1);
}
2 - “Trigger” :
private var startTime;
private var restSeconds : int;
private var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var countDownSeconds : float;
function Start () {
GetComponent("Color Change").enabled = false;
}
function Awake()
{
Reset();
}
function Reset()
{
startTime = Time.time;
}
function OnParticleCollision (other : GameObject){
Reset();
GetComponent("Color Change").enabled = true;
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
if (restSeconds == 0) {
print ("Time is Over");
GetComponent("Color Change").enabled = false;
}
}
function OnGUI () {
//display the timer
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
GUI.Label (Rect (400, 25, 100, 30), text);
}
p.s. should I make just one single script in which when the timer reaches 0, the material is just swapped back ? I don’t want to use Mathf.Pingpong, because the sphere should just only light up once for every particle collided.
Thanks!