Jump to content

position of collision?


jawm
 Share

Recommended Posts

i'm trying to make crates which can be moved by the player. the game is a platformer. I'm having the issue that when the player pushes the crate against a wall, they can no longer move it away from the corner. i want to make it so that when the player jumps on top of the crate it gets pushed to the side, thus getting it out of the corner. i'm not sure how to detect if the collision between the player and the crate is on the top. im using the arcade physics engine. is there any simple way of achieving this?

Link to comment
Share on other sites

In the collision callback you can get the body.touching object to tell you the direction of the collisions:

game.physics.arcade.collide(player, crates, function(player, crate) {  if (player.body.touching.down && crate.body.touching.up) {    // the player is colliding with this crate from above, so do something with this crate  }});
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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