Randomized weather, little stuck

Hi,

Edit: The main problem we’re having is finding an equation that fades an alpha blended material based on the game speed. If anyone can point us in the right direction or give us an example that’d be great. Once we figure this out then we can work on randomizing it.

So far we have everything figured out with our system, but we’re just a little stuck on the last part which is randomized weather. We have been at this for days and can not get it working.

We have a minute, hour, day, and month tracker. We have thunder, lightning, rain, everything, but we just need a way to enable them based on randomization.

How could we go about this? I think the easiest way would be to use a random.range then have an if statement get a random number, if that random number is reached, do the what’s in the if statement for a randomized period of time based off the global dayLength.

I’m a pretty decent programmer, I’m just not sure how to do the above. We also need to have the rain and clouds fade in and out when a storm approaches. So maybe have multiple if statement gradually fading the storm in then out?

Is there a better way of fading a material than this, it doesn’t seem to work correctly:

heavyClouds.renderer.sharedMaterial.SetColor ("_TintColor", Color.gray / dayLength);

If there is, how can I fade the fade time based on the dayLength, as our system has a global time that is all synchronized, like game minute, hours, days, cloud speed, ect.

This is a quick function which should take care of the could fading, but it doesn’t work right.

function weatherCalculator () { 

Hour = Random.Range(0, 24);
heavyClouds.renderer.sharedMaterial.SetColor ("_TintColor", Color.white /  
    dayLength);

if (Hour == 14)
{
Hour = Random.Range(0, 24);
heavyClouds.renderer.sharedMaterial.SetColor ("_TintColor", Color.gray /       
    dayLength);
yield WaitForSeconds (random*dayLength);
}

If anyone could help me out it’d be much appreciated. I’ll be sure to mark as answered if the answer gets this working.

Thanks

might be more elaborate than you're looking for, but one-dimensional perlin noise would do quite nicely. Searching perlin noise will give any number of examples. At the simplest, a single 1d perlin function could control both the clouds and rain; if you wanna get fancy, you could create multiple functions; one for cloudiness, one for rain, one for fog, etc, and multiply where appropriate - for example, it can't rain without clouds, so the rain value is multiplied by the cloudiness value, then if clouds is 0, it can't possibly rain, and the more clouds, the more rain.