On tiled physics ground or walls, prevent collision with wrong edge?

Hi all,

I’m beginning development of a platformer. I’m loading a tilemap and using it for collision. I have an issue where as my character walks along the ground they will sometimes collide with the left or right edges of each ground tile, causing them to lose their velocity. The same problem occurs when falling against a wall - the player can collide with the bottom and top of individual wall tiles making them bump their head or be able to land on sections of the wall.

To demonstrate the issue I branched a simple platformer test and added in some acceleration and found the same issues. If you run this project and walk along the ground you’ll find sometimes your velocity will be cancelled even though it doesn’t look like you’ve hit anything and if you jump while pressing into a wall you’ll bump your head then land in the wall.

The player script is here:

Any suggestions on how to tackle this? I was trying to filter out collisions or velocity resets based on the collision info but couldn’t think of logic that would do that without breaking the collision in other ways. If there was a way to combine adjacent tiles’ physics colliders if they’re the same so each ground or wall was one physics object that would be best, is there a way to do that?

This was discussed recently:
https://forum.defold.com/t/merge-tile-colliders

Also analyzed a while back:
https://forum.defold.com/t/directional-platforms-help

It’s difficult to get this working. You can switch to using ray casts instead of collision shapes between your tile map and characters. A helpful library in remedying this problem can be found here:

Defold can’t merge those tiles together to remove unwanted edges.
I am working on an alternative extension for box2d, where you can programmatically set width/height of each physics body. It’s more work, but should help with the issue. If you are interested you can try it via my Patreon.

Huh, I thought it would be a pretty standard problem so expected a standard solution. Oh well. Thanks for the leads, I’ll give Platypus a try!

1 Like

Is Platypus working out for you? I’m having problems with the raycasts allowing me to clip into tiles.

Did you configure it properly and specify raycast distance?

Yeah, I got it working. Had to muck around with the left, right, up, down and offset in the config for a bit to get collision to work properly. I figured it out from the example project in the platypus repo. Also if your character can move fast enough that they can get most the way through a tile in one frame they’ll get pushed out the other end so that might also be your problem?

1 Like