- Home /
Question by
brandonhotdo · Jul 26, 2013 at 11:51 PM ·
randomsystemnewrain
Rain Random
Hi. I'm kind of a noob when it comes to coding without the help of a youtube tutorial. so i've been trying to make a system when it will rain randomly and its has not been going so well. . .
#pragma strict
public var rainornot : int;
private var myLight : ParticleEmitter;
var myTimer : float = 10.0;
function Start ()
{
audio.Play();
myLight = GetComponent(ParticleEmitter);
}
function Update ()
{
if(Random.Range(1,40) == 2)
{
var rainornot = 1;
if(myTimer <= 0)
{
var rainornot = 0;
}
}
if(rainornot == 1)
{
myLight.enabled = !myLight.enabled;
}
if(myTimer > 0)
{
myTimer -= Time.deltaTime;
}
}
Comment
What is the question? Also, I reformatted your code, it made my eyes sad.
Best Answer
Answer by AlucardJay · Jul 27, 2013 at 12:07 AM
A couple of considerations :
rainornot is already declared as a global variable :
public var rainornot : int;
so if you want to modify that value, just call on the variable by name, don't declare it again :
rainornot = 1;