Hey, I’m new to Unity, and this will be my first post.
Anyway, I tried to make a automatic thunder script, like, you walk around in a house and all of a sudden thunder sound starts playing and the directional light increases it’s intensity.
I have the sound and obviously the directional light, but I don’t know how to make the light flicker.
I’m not very good with explaining but here’s how my script looks like so far:
using UnityEngine;
using System.Collections;
public class thunder : MonoBehaviour {
public float intens = 1.02f;
public int ThunderRate = 100;
public int ThunderRateRandom;
public bool on = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
ThunderRateRandom = Random.Range (0, ThunderRate + 1);
if(ThunderRateRandom == ThunderRate)
{
if(!on)
{
on = true;
light.intensity = intens;
audio.Play();
}
else
{
Update ();
}
}
}
}
I know that this script sucks ass but I’m very new to this stuff.
If anyone mind poiting me in the right direction on making the light flicker, it would be lovely :3
Thank you for reading.