Hi guy,
what I want to do is, when the blue is on the red is of, to blinking the light I think to use this for one colour at time of 0.5
// Pulse light's intensity over time
var duration : float= 0.5
function Update() {
// argument for cosine
var phi : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
var amplitude : float = Mathf.Cos( phi ) * 0.5 + 0.5;
// set light color
light.intensity = amplitude;
}
and this for the other who wait 0.5 then start at time of 0.5
var duration : float= 0.5;
var WaitForTime : 0.5;
var PulseOn : boolean = false;
function Update() {
if( WaitForTime >= 0.0)
{
WaitForTime -= Time.deltaTime;
}
if (WaitForTime <= 0)
{
PulseOn = true;
}
else if(WaitForTime <= 0)
PulseOn = false;
if(PulseOn) {
// argument for cosine
var phi : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
var amplitude : float = Mathf.Cos( phi ) * 0.5 + 0.5;
// set light color
light.intensity = amplitude;
}
}
it's work, but after waiting to start, the lights flashing at the same time, synchronized
I also try this to use one only script, I try various changes but not work, or only show one light and not cause console error or warning
#pragma strict
#pragma implicit
#pragma downcast
var duration : float= 0.5;
var WaitForTime : 0.5;
var WaitForTime_2 : 0.5;
var PulseOn : boolean = false;
var PulseOn_2 : boolean = false;
var color_1 : Color;
var color_2: Color;
function Update() {
if( WaitForTime >= 0.0)//( WaitForTime >= 0.0)
{
WaitForTime -= Time.deltaTime;
}
if (WaitForTime >= 0)//(WaitForTime <= 0)
{
PulseOn = true;
PulseOn_2 = false;
}
else if(WaitForTime <= 0)//(WaitForTime >= 0)
PulseOn = false;
PulseOn_2 = true;
if(PulseOn) {
// argument for cosine
var phi : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
var amplitude : float = Mathf.Cos( phi ) * 0.5 + 0.5;
// set light color
light.intensity = amplitude;
light.color = color_1;
}
if( WaitForTime_2 >= 0.0)
{
WaitForTime_2 -= Time.deltaTime;
}
if (WaitForTime <= 0)
{
PulseOn = false;
PulseOn_2 = true;
}
else if(WaitForTime >= 0)
PulseOn_2 = false;
PulseOn = true;
if(PulseOn_2) {
// argument for cosine
var phi_2 : float = Time.time / duration * 2 * Mathf.PI;
// get cosine and transform from -1..1 to 0..1 range
var amplitude_2 : float = Mathf.Cos( phi_2 ) * 0.5 + 0.5;
// set light color
light.intensity = amplitude_2;
light.color = color_2;
}
}
please where is error....I ear you rotfl for my code
asked
Aug 08 '12 at 08:03 PM
Ingen
145
●
3
●
12
●
20
...No news?