Jump to content

Endless Runner Glitch (Player gets stuck on platform)


Kraken
 Share

Recommended Posts

I recently started to learn phaser and JS and I was creating the endless runner tutorial and the game runs fine and I was able to add my own tweaks to it. I've noticed that when the platforms are created lower than the previous platform the player will get stuck at random. Anyone know what that issue could be? When I use the intel xdk emulator it works fine but when I test it on a browser or in the intel app previewer the player will get stuck.

 

Link to comment
Share on other sites

Enable debug on your bodies and see what happens better. 

Also I did an endless runner some weeks ago in Phaser with multiple platforms at different heights, enemies, etc and have absolutely no issue. Have you tinkered by any chance with the mass and gravity? Setting the mass too low may cause some glitches I think.

Link to comment
Share on other sites

Thanks scheffgames! I enabled debug and everything looked alright. I did change the gravity from 1500 to 900 and the frequency it happens is lower significantly which makes me believe that's what the problem is. Its funny though when I run it through the intel emulator everything works fine no matter the gravity but if I try it through intel previewer or chrome that's when it happens.

Link to comment
Share on other sites

I think the ratio between gravity and mass may be the issue, not the gravity itself - I've used 4000 gravity for my game without any problems.  Do you have a single rectangle body on your character? Or you're using something other than arcade physics? Because I know from Unity that polygon colliders have a nasty tendency to get stuck if they're too complex. Also make sure to clear your cache before reloading the game in the browser - you may still be using the old build - if you enable developer tools on Chrome with Ctrl + Shift + I (the console basically) you'll see a Network tab and when you click on it you'll have a checkbox called Disable Cache or you should clear your browser history after every change you make to scripts.

Other than that I'd be happy to take a look at the actual buggy code snippet or test in on my machine

Link to comment
Share on other sites

I'm using arcade physics, I have disabled the cache as you suggested this is basically my player code...

this.player = this.add.sprite(200, 200, 'player1');
    this.player.anchor.setTo(0.5);
    this.player.animations.add('running', [1,2,3,4,5,6], 10, true);
    this.player.animations.add('jumping', [7], true);
    this.game.physics.arcade.enable(this.player);
	this.player.body.setSize(58,83, 10, 11);

but as for the buggy code I honestly couldn't tell you what it would be as the game will be working fine and then the player gets stuck randomly. I did see the correlation between the gravity setting though I even increased it on the enemy bodies only and it seems to effect the player getting stuck as well. I lowered the gravity equally on everything and I get stuck very rarely now if at all. 

Link to comment
Share on other sites

Just to confirm... gravity was the issue now that I have set it to 1000 I no longer get stuck. Anything over that number somehow causes problems when the platform created is lower than the previous one. Thanks scheffgames, I honestly would of never thought it was the gravity. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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