hexus / phaser-arcade-slopes

:triangular_ruler: A Phaser CE plugin that brings sloped tile collision handling to the Arcade Physics engine
MIT License
126 stars 16 forks source link

Jump when in air and pressing left or right next to the wall (FULL) #20

Closed cmboros closed 7 years ago

cmboros commented 7 years ago

Really great plugin just got one issue.

Every time the player is near a wall (FULL) and i press to the direction of the wall it do wall jump. Is any way to prevent this?

Thanks

hexus commented 7 years ago

I can't really comment on why this is happening without seeing any example code.

cmboros commented 7 years ago

Thanks for the response I have create a gist https://gist.github.com/cmboros/6f469a7b22078a6ef4d22aefc8f2583e

Thnaks

hexus commented 7 years ago

https://gist.github.com/cmboros/6f469a7b22078a6ef4d22aefc8f2583e#file-player-js-L144-L155

These lines are why. Look at your conditions and what you're doing within them.

if (this.body.touching.right) {
    if (this.jumpButton.isDown) {
        this.scale.x = this.scale.x * -1;
        this.body.velocity.y = -300;
        this.body.acceleration.x = -20000;
    }
} else if (this.body.touching.left) {
    if (this.jumpButton.isDown) {
        this.scale.x = this.scale.x * -1;
        this.body.velocity.y = -300;
        this.body.acceleration.x = 20000;
    }
} else {
    this.body.acceleration.x = 0;
}

All I had to do to find this was search body.velocity.y.

If you want to make sure the player is on the ground when this runs, just wrap these blocks with a check for touching.down:

if (this.body.touching.down) {
    ...
}

Also, celery is the best weapon. :smiling_imp:

cmboros commented 7 years ago

Thanks a lot for the help. I forgot about that condition i just had to remove it.

Celery is useful when you fight with some other vegetables :).

Thanks again:)