lonelydatum Posted July 18, 2014 Share Posted July 18, 2014 Collision between my hero and polygon (ramp) penetrates through the polygon. Here is an image of what I mean. This loads the json file;this.game.load.physics('rampPolygons', 'assets/gameplay/ramps/exports/ramps_physics.json'); This is the co-ordinates for the polygon.{ "ramp0": [{"density": 2, "friction": 0, "bounce": 0, "filter": { "categoryBits": 1, "maskBits": 65535 },"shape": [ 0,0, 80,-30, 160,-90, 160,0, 0,0 ] } ] } This applies the polygon to the ramp spriteramp.body.clearShapes();this.body.loadPolygon("rampPolygons", ramp0 ); Link to comment Share on other sites More sharing options...
iforce2d Posted July 19, 2014 Share Posted July 19, 2014 The ramp polygon is concave, so you would need to compose it from separate convex polygons. Fortunately, it looks like p2 already has what you need:http://schteppe.github.io/p2.js/docs/classes/Body.html#method_fromPolygonhttps://github.com/schteppe/p2.js/blob/master/demos/concave.html Link to comment Share on other sites More sharing options...
Recommended Posts