Jump to content

Collision triggering .down when on the side?


MTiger
 Share

Recommended Posts

I was working with a popular online tutorial in making an infinite runner game.
All goes well, except there seems to be this one instance that pushed the player off the screen. (keeping player at velocity 0 instead of -platformSpeed).
I think the issue is with this line

this.player.body.velocity.x = this.player.body.touching.down ? -this.levelSpeed: 0;

It seems to happen when the player catches the very corner of the platform, and isdown does not get set, then the player is "pushed" onto the platform. But this is just a logical guess as it happens too fast to debug.

The collision check happens in a line above

  this.platformPool.forEachAlive(function (platform, index) {
        this.game.physics.arcade.collide(this.player, platform);

        if (platform.length &&
            platform.children[platform.length - 1].right < 0) {
            platform.kill();
        }
    }, this);


    
My full code is here, but I can't figure a way to get the assets to load 

http://jsbin.com/tufisagoho/edit?html,js,output (updated link with Hosted Assets)

Edited by MTiger
updated link with Hosted Assets)
Link to comment
Share on other sites

This won't give an answer to your problem, but when setting the player its body to a circle, you should not be able to reproduce your problem:

 this.player.body.setCircle(40,-15,-15); 

Maybe it will give you more insight in what might be the cause (I was not able to dig into the code). Maybe you could ask the developer who published the tutorial?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...