Jump to content

position of collision?


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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...