I am making a script for a light that is supposed to make the light flash. Although when I tested it It did not work and nothing happened. Can anybody help?
// initialize code called once per entity
LightFlash.prototype.initialize = function() {
};
//Define Flash
LightFlash.prototype.Flash = function() {
this.entity.enabled = false;
window.setTimeout( function(){
this.entity.enabled = true;
}.bind(this), 1000);
};
// update code called every frame
LightFlash.prototype.update = function(dt) {
this.Flash();
};
// swap method called for script hot-reloading
// inherit your script state here
// LightFlash.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/
You can’t use a timeout inside the update function and that’s what you basically do right now. Please check your topic below, I think you can use that here too.