Cannot Get Light To Flash - Help


I have a beacon light within a game object on my scene. What I want it to do is simply flash on and off every second, but its just not doing anything - it just remains on.

Here is my script:

var BeaconLight : Light;
var Triggered : boolean = false;
var WarningSound : AudioClip;

function Start(){
    InvokeRepeating("Beacon", 0, 1);

function Beacon(){
    BeaconLight.light.intensity = 1;
    yield WaitForSeconds(1);
    BeaconLight.light.intensity = 0;

I also tried using: BeaconLight.enabled = false;

I have a feeling its to do with my timer, and how it gets invoked?

Please help me out.

Thank, Ollie

You can't use InvokeRepeating for coroutines. You don't need to explicitly set 1 or 0 anyway; you can just alternate between them, so the function doesn't need to be a coroutine.

// Use lowercase for variable names; it's less confusing
var beaconLight : Light;
var triggered : boolean = false;
var warningSound : AudioClip;

function Start(){
    beaconLight.intensity = 0;
    InvokeRepeating("Beacon", 0, 1);

function Beacon(){
    // beaconLight is already a Light, so you don't need to refer to .light
    beaconLight.intensity = 1-beaconLight.intensity;
    // You don't need "return" at the end of functions. They stop anyway.