Jump to content

Collision and jump problem


RatonPaladin
 Share

Recommended Posts

Hi guys! I need your help, forgive me if my english is a little bit ugly (I'm French)

 

Actually I'm trying to make a game with Phaser, and my player can jump.

The problem is the condition:

 

if (player.body.touching.down)

{

  //jump settings

}

 

With the "touching.down", anytime the player hits something under him, he can jump (so if he walks on a baddie, on objects, on platform without collisions etc). Is there a way to allow the player to jump ONLY when he is on a "OK" platform with collisions?

( Overlap doesn't works because of the collide "this.physics.arcade.collide(this._player, this._g_platforms);" )

( Blocked.down only works for the world bounds, that's not what I want :/ )

 

Thanks!

Link to comment
Share on other sites

Hi I had the same problem, the solution is to use tilemaps, so you can use player.body.onFloor();

 

from the docs:

 
onFloor() → {boolean}  

Returns true if the bottom of this Body is in contact with either the world bounds or a tile.

 

 

 

perhaps there is another way to do this, but I think tilemaps are the best solution for differentiate the platform and the objects.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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