mBeierling Posted July 6, 2015 Share Posted July 6, 2015 I use the Ninja Physics library and am very happy with it. Sadly, the "touching" object won't detect collisions for non-full tiles. I use the Circle as shape for my player. Is there a function I'm missing, or is there a known workaround for this? Link to comment Share on other sites More sharing options...
mBeierling Posted July 7, 2015 Author Share Posted July 7, 2015 My workaround: In "phyiscs/ninja/Circle.js" I change: if (dx === 1) { this.body.touching.left = true; } else if (dx === -1) { this.body.touching.right = true; } if (dy === 1) { this.body.touching.up = true; } else if (dy === -1) { this.body.touching.down = true; }To: if (dx === 1) { this.body.touching.left = true; } else if (dx === -1) { this.body.touching.right = true; } if (dy === 1) { this.body.touching.up = true; } else if ((dy <= -0.2 && (dx <= -0.2 || dx >= 0.2) ) || dy === -1) { this.body.touching.down = true; }After some tweaking, 0.2 as a limit for the normals works best for the tile shapes I use in my project. Link to comment Share on other sites More sharing options...
Recommended Posts