When i run this code it says Uncaught ReferenceError: Jump is not defined?

var onGround=false
var jumpForce = 4;

Jump.prototype.initialize = function() {
    // Define Events
    this.app.keyboard.on(pc.EVENT_KEYDOWN, this.onKeyDown, this);
    this.app.keyboard.on(pc.EVENT_KEYUP, this.onKeyUp, this);
    this.entity.collision.on('collisionstart', this.onCollisionStart, this);

Jump.prototype.update = function(dt) {
    // Jump
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE) && onGround === true) {
        this.entity.rigidbody.applyImpulse(0, jumpForce, 0); // Apply Impulse
        onGround = false; // Set onGround variable to false

Jump.prototype.onCollisionStart = function(result) {
    // Ground Check
    if (result.other.tags.has('ground')) {
        onGround = true;

Hi @MATURE! The first line of the script is missing. Please compare the first line of your script with the first line of another script.

1 Like

It looks like the object “Jump” is not defined in the code, or it can’t be found.

To define it, add this line at the start of your code.
var Jump = pc.createScript('jump');