# alternate light problem

 0 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, synchronizedI 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 more ▼ asked Aug 08 '12 at 08:03 PM Ingen 145 ● 3 ● 12 ● 20 ...No news? Aug 10 '12 at 05:03 AM Ingen add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 You are using Time.time / duration * 2 * Mathf.PI for both lights. Time.time is the same in both cases, so that is why they are synchronized. You want to doe something like (Time.time + duration/2) for one of the lights. more ▼ answered Aug 10 '12 at 11:54 AM I need at the same speed but if one star a bit after,should blink alternatingI also try time 1 and wait 0.5, but not work Aug 11 '12 at 11:04 AM Ingen add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x445
x249
x1

asked: Aug 08 '12 at 08:03 PM

Seen: 276 times

Last Updated: Aug 11 '12 at 11:06 AM