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:
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
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:
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.
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.