Arcade gravity not working

Hello everyone, I have a pretty basic problem. Gravity system is not working for me.

    const config = {
            type: Phaser.AUTO,
            width: 640,
            height: 360,
            parent: 'phaser-game',
            physics: {
                default: 'arcade',
                fps: 60,
                gravity: { y: 300 },
                arcade: { debug: true }
            },
            scene: [Scene]
        }

and in update function I have something like that:

  update() {
        if (this.cursors.up.isDown) {
            this.player.setVelocityY(-Math.abs(this.player.body.velocity.x));
        }

    }

Example:
https://dbrebirth.zaba.ovh/

Just hold right arrow and click up arrow.

Your gravity acceleration needs to be at config.physics.arcade.gravity instead of config.physics.gravity.

const config = {
    type: Phaser.AUTO,
    width: 640,
    height: 360,
    parent: 'phaser-game',
    physics: {
        default: 'arcade',
        fps: 60,
        arcade: {
            gravity: { y: 300 },
            debug: true
        }
    },
    scene: [Scene]
}
1 Like

Yup, that was that. Thank you very much!