# Merge tile colliders

**URL:** <https://forum.defold.com/t/merge-tile-colliders/64339>\
**Category:** Questions\
**Created:** [January 25, 2020, 4:14am UTC](https://forum.defold.com/t/merge-tile-colliders/64339 "2020-01-25T04:14:42Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthroyd](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/anthroyd/32/19574_2.png) [@Anthroyd](https://forum.defold.com/u/Anthroyd)\
**Post date:** [January 25, 2020, 4:14am UTC](https://forum.defold.com/t/merge-tile-colliders/64339/1 "2020-01-25T04:14:42Z")

</div>

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:

 ![Capture](https://forum-defold.b-cdn.net/uploads/default/original/3X/a/a/aa85f59dc6938ca75dac5c2a27c25d5eb72c449b.png)  
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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 25, 2020, 8:16am UTC](https://forum.defold.com/t/merge-tile-colliders/64339/2 "2020-01-25T08:16:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anthroyd](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/anthroyd/32/19574_2.png) [@Anthroyd](https://forum.defold.com/u/Anthroyd)\
**Post date:** [January 25, 2020, 4:46pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/3 "2020-01-25T16:46:53Z")

</div>

The screenshot is from the platformer tutorial: [Platformer Defold 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](https://forum-defold.b-cdn.net/uploads/default/original/3X/f/a/fac3b207efe2a0c39f0a1deabe702370b0467b39.png)

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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 25, 2020, 5:31pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/4 "2020-01-25T17:31:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anthroyd](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/anthroyd/32/19574_2.png) [@Anthroyd](https://forum.defold.com/u/Anthroyd)\
**Post date:** [January 25, 2020, 5:37pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/5 "2020-01-25T17:37:58Z")

</div>

```
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](https://forum-defold.b-cdn.net/uploads/default/original/3X/3/3/330979066c4d2c8c3b58973e5152122064361754.png)  
 ![2](https://forum-defold.b-cdn.net/uploads/default/original/3X/4/0/40bbb910b5e28c5c9a10350cd86c726b651f4a75.png)

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

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 25, 2020, 8:38pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/6 "2020-01-25T20:38:08Z")

</div>

This might be related to [this post](https://forum.defold.com/t/directional-platforms-help/18764/31). 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](https://forum.defold.com/t/box2d-chain-shapes/54586).

---

<div class="post-metadata">

**Author:** ![totebo](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/totebo/32/36087_2.png) [@totebo](https://forum.defold.com/u/totebo)\
**Post date:** [January 25, 2020, 8:50pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/7 "2020-01-25T20:50:16Z")

</div>

> [@Anthroyd](#):
>
> ![Capture.PNG](https://forum.defold.com/uploads/default/original/3X/a/a/aa85f59dc6938ca75dac5c2a27c25d5eb72c449b.png)
> 
> How can I get my tiles to stitch their sides together?

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?

---

<div class="post-metadata">

**Author:** ![Anthroyd](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/anthroyd/32/19574_2.png) [@Anthroyd](https://forum.defold.com/u/Anthroyd)\
**Post date:** [January 25, 2020, 9:20pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/8 "2020-01-25T21:20:21Z")

</div>

Hey, I posted a link to the tutorial a few replies above: [Platformer Defold tutorial](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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 25, 2020, 10:29pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/9 "2020-01-25T22:29:03Z")

</div>

> [@Anthroyd](#):
>
> 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:

- [Platypus](https://defold.com/assets/platypus)
- [True Tile Collisions](https://defold.com/assets/truetilecollisions)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 25, 2020, 10:33pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/10 "2020-01-25T22:33:53Z")

</div>

> [@Anthroyd](#):
>
> It’s strange because the platformer seems to work properly, regardless of the fact that it uses tiles for its walls.

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.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 25, 2020, 10:34pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/11 "2020-01-25T22:34:34Z")

</div>

The project is here btw: [GitHub - defold/tutorial-platformer: Files for the platformer tutorial found here: https://www.defold.com/tutorials/platformer/ · GitHub](https://github.com/defold/tutorial-platformer)

---

<div class="post-metadata">

**Author:** ![Anthroyd](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/anthroyd/32/19574_2.png) [@Anthroyd](https://forum.defold.com/u/Anthroyd)\
**Post date:** [January 25, 2020, 10:55pm UTC](https://forum.defold.com/t/merge-tile-colliders/64339/12 "2020-01-25T22:55:51Z")

</div>

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.
