Hey! I need help to making a script for toggling the flashlight
var Flashlightcontroller = pc.createScript('flashlightcontroller');
Flashlightcontroller.prototype.initialize = function() {
this.entity.root.findByName('Player light').enabled = false;
};
Flashlightcontroller.prototype.update = function(dt) {
if (this.app.keyboard.isPressed(pc.KEY_F)){
this.entity.root.findByName('Player light').enabled = true;
}
else if (this.app.keyboard.wasPressed(pc.KEY_F)){
this.entity.root.findByName('Player light').enabled = false;
}
};
Here’s the script i created but Im sure something is missing or wrong.