i already have myself a switch camera script, but it works only with a ui button so i would like to know how to do that with a keypress, i do not know how to do that
var SwitchCamera = pc.createScript('switchCamera');
SwitchCamera.attributes.add('firstPCamera', {
type: 'entity',
title: 'FirstPCamera'
});
SwitchCamera.attributes.add('thirdPCamera', {
type: 'entity',
title: 'ThirdPCamera'
});
SwitchCamera.attributes.add('switchButton', {
type: 'entity',
title: 'switchButton'
});
// initialize code called once per entity
SwitchCamera.prototype.initialize = function () {
this.switchButton.button.on("click", this.onSwitchButtonClick, this);
};
SwitchCamera.prototype.onSwitchButtonClick = function () {
this.firstPCamera.enabled = !this.firstPCamera.enabled;
this.thirdPCamera.enabled = !this.thirdPCamera.enabled;
};
// update code called every frame
SwitchCamera.prototype.update = function (dt) {
};
// swap method called for script hot-reloading
// inherit your script state here
// SwitchCamera.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/