I’m trying to make a Mario style platformer where you can break/trigger blocks by hitting them from below and this is being a real pain. I have collision detection working fine for the most part, my issue comes with detecting simultaneous collisions between multiple side-by-side tiles.
If my player sprite comes into contact with the corners where two tiles meet, a callback is only made for one of the tiles. I’d prefer it to only trigger for the tile that contacts the center of the player sprite, but it seems to favour the object last added to the group regardless of the position of the player.
A callback is made for both tiles when the player body is a circle, but that comes with other complications I’d rather avoid.
Here’s the collision code in my player class:
this.scene.physics.world.collide(this, this.scene.tilegroup, function(obj1, obj2) {
console.log(obj1, obj2);
obj2.alpha = 0.2
});
I’m wondering if there’s a workaround for my issue or if it’s just a limitation with arcade physics. Thanks!