Merge tile colliders

My major issue with tile collisions has been the fact that you can “bump” into tiles that are next to each other. I can actually wall climb a solid wall using this physics glitch. I just read over the Platformer tutorial, and noticed this:


How can I get my tiles to stitch their sides together? I don’t see any option for this and Defold hasn’t been doing this automatically for me.

Since you use irregular shaped tiles and use the tile graphics itself to trace the collision shape you will potentially run into problems like this. My recommendation would be to use a different PNG for the collision shapes with completely square tiles for the walls instead of the irregular ones tracing the outline of the vines etc

The screenshot is from the platformer tutorial: https://defold.com/tutorials/platformer/
The irregular shaped tiles are from the tutorial.

My tiles are a 32 x 32 solid square shape. An example:

Capture

I’m able to grip the points where tile meets tile and “climb” walls, as well as sometimes bump into adjacent tiles on the ground.

How are you resolving the collisions? Try a sphere collider for your player character as well

local cancel_component = vmath.dot(self.correction, normal)
local remaining_component = (distance - cancel_component) * normal
self.correction = self.correction + remaining_component
go.set_position(go.get_position() + remaining_component)
if utility.compare_normal(normal, 0.5, true) then
	self.grounded = true
end
cancel_component = vmath.dot(self.velocity, normal)
if cancel_component < 0 then self.velocity = self.velocity - cancel_component * normal end

It’s the same method used in the platformer tutorial (only my “grounded” normal is set to 0.5 instead of 0.7, which doesn’t affect anything.) Spheres see the same problem.

Here’s what the tilesource looks like in case it helps:

Capture

(Those 5 pure white squares to the right are not actually tiles, just blank spots in the png file.)

This might be related to this post. If so, there is no simple way in Defold to avoid this problem. Possible solutions that are discussed in the post:

  • It might be mitigated by updating the Box2D version Defold uses.
  • Adding a composite collider to Defold, like the one in Unity.
  • Adding chain shapes to Defold.
1 Like

Do you have a link for this tutorial? As far as I know, Defold doesn’t support edge shapes, so I’m guessing the image is not for a Defold tutorial?

Hey, I posted a link to the tutorial a few replies above: https://defold.com/tutorials/platformer/

It’s strange because the platformer seems to work properly, regardless of the fact that it uses tiles for its walls. I understand why this is happening, but I figured Defold would have an easy workaround, since it explicitly states that it has an easy workaround in the tutorial (“stitching” edges together that are perfectly aligned.)

I’m sure I can figure out how to fight those individual frames of unwanted collisions, but since Defold has been out for a couple years, and so many other games have been made using tilemaps, I assumed the solution would be easy public knowledge by now.

What does it look like if you enable physics debugging? Enable it via a checkbox in game.project Physics section or via a message:

msg.post("@system:", "toggle_physics_debug")

There’s also Platform engines you can use if you don’t want to do all of the work yourself:

From the looks of the tutorial I actually don’t think it uses tiles in the playable version on that page. From the screenshots it looks like the walls are separate rectangular physics shapes sized to cover the graphics.

2 Likes

The project is here btw: https://github.com/defold/tutorial-platformer

1 Like

That’s interesting, thanks for letting me know and linking to the project as well. I’ll make sure to update this thread once I decide on a solution.

1 Like