0

This is my first question here, so I'll do my best. I'm programming a 2D tile based platformer using Javascript and HTML5 Canvas. I Use EaselJS as my renderer and PhysicsJS for my collision detection. I've made a map with 'Tiled Map Editor'.

My problem is with the collision detection. It is definitely working, but the problem is that I get too many collisions. My tiles are next to each other, edge-to-edge. The problem with this is that every tile has multiple collisions with the ones around them. Is there any way working around this? So basically I 'only need collision detection on the outer edges of the tiles, who are not connected to another tile'.

I've already made my bodies 1px smaller than my actual images, but I don't think thats the good way.

Thanks in advance

Sven Lombaert
  • 85
  • 1
  • 7
  • A while back I made a mashup for a project that reads maps from tiled and creates Box2D elements and renders it to EaselJS, this has not a lot to do with PhyricsJS, that's why I'm posting it as a comment, not an answer, but just in case you might want to take a look at the source, maybe you find something helpful there for your issue: https://github.com/olsn/BoxledJS – olsn Dec 29 '13 at 21:57
  • Thanks, will definitely check this out! – Sven Lombaert Dec 30 '13 at 09:45
  • I think the ideal way to do this would be to create a new behavior like the edge-collision-detection, but allow custom shapes for platforms. At the moment though, I think your solution to make the bodies 1px smaller is pretty good (it ensures the sweep prune handles things optimally). You could also use floating point numbers too to get things really close but not touching. eg: trailing edge at 200, next leading edge at 200.00001 – Jasper Dec 30 '13 at 16:12
  • Thanks for the comment @Jasper. For now, it'll do to making the bodies 1px smaller. I've also converted my project by not using physicsjs and writing my own collision detection which runs just fine now. I think it's the better choice for a (relative simple) platformer than using a real physics engine. I'll definitely keep an eye on physicsjs for other projects and experiments though. – Sven Lombaert Dec 30 '13 at 23:44

0 Answers0