Trying to create a thunder and lightning effect which will start as the player enters a certain area. Was using two very simple scripts before to get the effects I need and separately both did what was expected.
Now I want both effects to happen at the same time in conjunction with a trigger.
My problem being is that now the light effect doesn’t flicker, it simply (randomly) either turns on or not once the trigger is activated.
I’m not getting any errors and everything runs fine, just the damn light doesn’t flicker ?
Sound effect code-
#pragma strict
var Thunder1 : AudioClip;
function OnTriggerEnter()
{
audio.PlayOneShot(Thunder1);
}
Light flicker code-
var FlashingLight : Light;
FlashingLight.enabled = false;
function FixedUpdate ()
{
var RandomNumber = Random.value;
if(RandomNumber<=.4)
{
FlashingLight.enabled = true;
}
else
FlashingLight.enabled=false;
}
This is the hybrid script (obviously I’m doing something wrong)?
#pragma strict
var Thunder1 : AudioClip;
var FlashingLight : Light;
FlashingLight.enabled = false;
function OnTriggerEnter()
{
audio.PlayOneShot(Thunder1);
var RandomNumber = Random.value;
if(RandomNumber<=.4)
{
FlashingLight.enabled = true;
}
else
FlashingLight.enabled=false;
}
Any help would be appreciated guys?