1/10/17

How to make a Flashing light

Hello guys, this tutorial is perfect to post apocaliptic games or horror games, the efect of flashing light, perfect to descomposed lamps.






Create a point light or a spotlight

Create a javascript and put this script:


var lights : Light;
var tiem : float;
var tiems : float[];

function Start(){
lights = GetComponent.<Light>();
}

function Update(){
tiem -= Time.deltaTime;
if(tiem <= 0){
if(lights.enabled == true){
tiem = Random.Range(0.1, tiems[0]); //off
lights.enabled = false;
}else{
tiem = Random.Range(0.1, tiems[1]); //on
lights.enabled = true;
}
}
}



Asign the script to your light

Set the variables like the image


In 'tiems', the element 0 is the maxime time that will happen off, the element 1 is the maxime time that will happen on.



Any doubts, do not forget to comment, and recommend n_n

No comments:

Post a Comment