[HELP] Scary Lamp-Script

Hello,

I’m already busy with a script for a lamp to flash so the light is a scary … but say 5 seconds, then flashes 2 times … Then 5 seconds …

I already have a script, but it remains all the time flashing. How do I make this script properly? (or someone in it for me)

Thank you!
( i’m dutch)

I have found this… ( here on the forum) Can i make it with the 5 seconds and 2-flash times?

    // Properties
    var waveFunction : String = "sin"; // possible values: sin, tri(angle), sqr(square), saw(tooth), inv(verted sawtooth), noise (random)
    var base : float = 0.0; // start
    var amplitude : float = 1.0; // amplitude of the wave
    var phase : float = 0.0; // start point inside on wave cycle
    var frequency : float = 0.5; // cycle frequency per second
     
    // Keep a copy of the original color
    private var originalColor : Color;
     
    // Store the original color
    function Start () {
        originalColor = GetComponent(Light).color;
    }
     
    function Update () {
      var light : Light = GetComponent(Light);
      light.color = originalColor * (EvalWave());
    }
     
    function EvalWave () {
      var x : float = (Time.time + phase)*frequency;
      var y : float;
     
      x = x - Mathf.Floor(x); // normalized value (0..1)
     
      if (waveFunction=="sin") {
        y = Mathf.Sin(x*2*Mathf.PI);
      }
      else if (waveFunction=="tri") {
        if (x < 0.5)
          y = 4.0 * x - 1.0;
        else
          y = -4.0 * x + 3.0;  
      }    
      else if (waveFunction=="sqr") {
        if (x < 0.5)
          y = 1.0;
        else
          y = -1.0;  
      }    
      else if (waveFunction=="saw") {
          y = x;
      }    
      else if (waveFunction=="inv") {
        y = 1.0 - x;
      }    
      else if (waveFunction=="noise") {
        y = 1 - (Random.value*2);
      }
      else {
        y = 1.0;
      }        
      return (y*amplitude)+base;     
    }

Whoah, that’s a scary script

I’d say for something like a blinking lamp you could use something a lot simpler, like a sin function

if you use the sin of Time.time, times it by a multiplier to really control the speed, and then set up a clamp (so the value doesn’t drop below 0)

To get something extra random and scary looking make the multiplier a random value between two constants so the time between curves is random and speeds up in different places

lamp.intensity = Mathf.Sin(Time.time * Mathf.RandomRange(minMultiplier,maxMultiplier);

You also don’t want the lamp’s intensity to be negative so we’ll add a Max

lamp.intensity = Mathf.Max(0,lamp.intensity);

So if the intensity is above 0, then the Mathf.Max picks the intensity to be it’s value, but if it’s below 0, then it picks 0

And that’s all there is too it!

Any questions feel free to PM me on the forums. Good luck with you’re scary game!