Hello! I am making a pause menu for my game, and to toggle the pause menu, you have to press the key p. But for some reason it’s not working. Here is my script. Thank you!
var Pause = pc.createScript('pause');
// initialize code called once per entity
Pause.prototype.initialize = function() {
this.toggle = 0;
};
// update code called every frame
Pause.prototype.update = function(dt) {
var app = this.app;
if (app.keyboard.wasPressed(pc.KEY_P)) {
if (this.toggle === 0) {
this.app.timeScale = 0;
this.toggle = 1;
}
if (this.toggle === 1) {
this.app.timeScale = 1;
this.toggle = 0;
}
}
};
// swap method called for script hot-reloading
// inherit your script state here
// Pause.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// https://developer.playcanvas.com/en/user-manual/scripting/