Hi, I need for my script when an entity is disabled the script will be enabled.
Here’s my script:
var FlashlightController = pc.createScript(‘flashlightController’);
FlashlightController.prototype.initialize = function() {
this.light = this.entity.root.findByName(‘Player light’);
this.light.enabled = false;
this.enabled = false;
};
FlashlightController.prototype.update = function(dt) {
if (this.entity.root.findByName(‘Flashlight trigger’).enabled == false) {
this.enabled = true;
}
if (this.enabled && this.app.keyboard.isPressed(pc.KEY_F)) {
if (!this.keyDown) {
this.light.enabled = !this.light.enabled;
this.keyDown = true;
}
} else {
this.keyDown = false;
}
};