How can I make my character jump?

You have to attach a script & make sure the player has a rigidbody & collision component attached to it. Make sure the rigidbody is type Dynamic. Then code a script similar to this:

//Variables
var force = 600; //You can change the value if you want.

NewScript.prototype.initialize = function() {
    this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
};

NewScript.prototype.update = function(dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.entity.rigidbody.applyImpulse(0, force, 0);
    }
};
1 Like