Jump to content

Way to solve sticking to tiled walls in p2 physics without using polylines


nomolosvulgaris
 Share

Recommended Posts

I'm trying to implement a platformer using p2 physics. There's known issue with tiles converted to collide boxes with p2.convertTilemap(). I can propose an example of how it affects gameplay: http://codepen.io/anon/pen/lJGqB. It turns out that length of narrowphase.contactEquation list sometimes is 0 even when the player crashes into the tiled wall. The issue is being discussed from time to time (e.g. http://www.html5gamedevs.com/topic/8895-p2-when-the-player-touches-a-wal-over-the-side-it-gets-stuck/) but seems to have no other solution but "use polylines instead of tiles". The trouble is that my tilemaps already have lots of collide tiles. So I wonder if there is a way to modify checkIfCanJump() function (the function is taken from http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=tilemap+gravity.js&t=tilemap%20gravity and in my example is modified as playerTouching() according to http://www.html5gamedevs.com/topic/6502-bodytouchingdown/). Maybe I should tinker deeper with threshold = 0.5 or use different collide equation list than p2.world.narrowphase.contactEquations.

Link to comment
Share on other sites

well.. you already linked to one of the threads where i wrote something about that.. the only thing i can say is that using polygons isn't going to solve it entirely anyways..   what actually worked is reducing the friction to 0

 

you could use several approaches to do this..  you mentioned the checkIfCanJump() function.. you can modify this function to find out if the body is touchingRight or touchingLeft  and if this is true set the friction of the body to 0 (apply another material) and the moment this is false again switch back to it's normal material..

Link to comment
Share on other sites

what actually worked is reducing the friction to 0

 

I guess it helps to prevent player sprite from trembling while jumping into the wall. It's not exactly the topic but it's really helpful. Here's the example of zero friction when left or right side is touching (in case I got it right): http://codepen.io/anon/pen/CfaBb

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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