[SOLVED] How to add Flickering Lights

pretty self expanatory, flickering lights, lights that turn on an off at a random time
Flickering Lights GIFs - Get the best GIF on GIPHY
flickering lights

how do you do that in playcanvas

Hi @Deadshot1m24,

Here is one way to do it using the PlayCanvas tween library:

var FlickeringLights = pc.createScript('flickeringLights');

FlickeringLights.prototype.initialize = function() {
    this.lightIntensity = {value: 1};

        .to({ value: 2 }, pc.math.random(0.5, 1.0), pc.ElasticIn)
        .on("update", (dt) => {
            this.entity.light.intensity = this.lightIntensity.value;

And a sample project:


Here is a random light script I made. It has a few script attributes that can be changed.



your script is quite nice but i dont require it i dont need to put in the extra work to get a quite similar result, i am happy with what i have now but thanks for the help :slight_smile:

working quite well :slight_smile:

1 Like

the issue with that one is it doesn’t really randomize, but loops.