Hello!
I have made a simple jumping script but if I press space (spamming it) then I keep jumping up and up and up. How can you fix this problem? Here is the link to editor (Go to act 4) PlayCanvas | HTML5 Game Engine
Here is the script:
var Jumping = pc.createScript('jumping');
// initialize code called once per entity
Jumping.prototype.initialize = function() {
};
// update code called every frame
Jumping.prototype.update = function(dt) {
if(this.app.keyboard.wasPressed(pc.KEY_SPACE) === true){
this.entity.rigidbody.applyImpulse(0, 5, 0);
}
};
// swap method called for script hot-reloading
// inherit your script state here
// Jumping.prototype.swap = function(old) { };
// to learn more about script anatomy, please read:
// http://developer.playcanvas.com/en/user-manual/scripting/