# Tilemap collisions not working when layer is invisible

**URL:** <https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653>\
**Category:** Bugs\
**Created:** [March 18, 2020, 6:59am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653 "2020-03-18T06:59:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 18, 2020, 6:59am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/1 "2020-03-18T06:59:49Z")

</div>

I found out, that when I **uncheck “Visible”** property of a layer of a tilemap it is **not considered for collision shape anymore** made from this tilemap.

I didn’t find any information about it, so I think this is a bug, because no “visibility” shouldn’t mean that I don’t want collision objects of those shapes.

Simple use-case - I made a level collisions layer, and a decorative level layer and I want only to display decorative layer, but use collisions from level collisions layer. I don’t want it to be in two different tilemaps, because it would complicate editing them. Separating it is useful, because I can create a regular shape (for ex. a 45 degree slope), but in decorative layer use some complicated grass, stairs or something like that, which shape is not good for a platformer character to move on smoothly.

I do not want collisions to be disabled like that, so another property “Collisions enabled for a layer” or something like that is needed.

In the following project you can check the Visible property of layer “collisions” marked and unmarked in tilemap.tilemap.

[Empty Project.zip](https://forum.defold.com/uploads/default/original/3X/1/3/139a34706eeb5f8a16e69d9b5c8cbd78371f44b0.zip) (97.6 KB)

---

<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:** [March 18, 2020, 7:06am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/2 "2020-03-18T07:06:16Z")

</div>

> [@Pawel](#):
>
> I didn’t find any information about it, so I think this is a bug, because no “visibility” shouldn’t mean that I don’t want collision objects of those shapes.

This is definitely up for debate. I would argue that if the layer isn’t visible then it should not interact with collision shapes.

You can differentiate between visuals and collisions shapes in the tilesource ([Defold tile source manual](https://defold.com/manuals/tilesource/#tile-source-collision-shapes))

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 18, 2020, 7:16am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/3 "2020-03-18T07:16:57Z")

</div>

> [@britzl](#):
>
> This is definitely up for debate.

Of course 😉

> [@britzl](#):
>
> You can differentiate between visuals and collisions shapes in the tilesource

This is the approach I’m currently using (one image used only for collision shape with color information, but another one used only for decorative layer with erased tiles that were used for collision) and while I agree that this workaround works, I can’t say that this is a convenient approach, because I need to have two images (and unfortunately they must be of the same size).

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [March 17, 2021, 8:42am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/4 "2021-03-17T08:42:43Z")

</div>

Bumping it up for a debate:

Many times visuals are different than collisions and, even if I set collision layer z under visual layer, it is sometimes visible: 😕

 ![image](https://forum-defold.b-cdn.net/uploads/default/original/3X/9/0/90441836c09d5b310b510d97888f3c0bfcc9b5fe.png)

Yet I don’t want to make more images for all the tilesources to prevent this as I described above. I know it’s not a priority issue, but maybe a quick solution is possible?  
Maybe another property flag for tilemap layers:

**Collisions** : ☑

or something like that could solve this? As a way easier and faster way than two images to differentiate collisions and visuals in tilemaps?

Something like this:

 ![collisions](https://forum-defold.b-cdn.net/uploads/default/original/3X/5/c/5cc6b683318eb0da74e6599f80dfd3941e7f8baf.png)

---

<div class="post-metadata">

**Author:** ![Rayburn](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/rayburn/32/27461_2.png) [@Rayburn](https://forum.defold.com/u/Rayburn)\
**Post date:** [February 13, 2022, 11:01pm UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/5 "2022-02-13T23:01:11Z")

</div>

+1

---

<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:** [February 14, 2022, 9:58am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/6 "2022-02-14T09:58:44Z")

</div>

Is there an issue for this on GitHub? It doesn’t look like it:

> **[defold/defold](https://github.com/defold/defold/issues?q=is%3Aissue+is%3Aopen+label%3Atilemap)**
>
> Defold is a completely free to use game engine for development of desktop, mobile and web games. - defold/defold

In order for us to consider it in the future we need it as a feature request!

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [February 14, 2022, 11:20am UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/7 "2022-02-14T11:20:45Z")

</div>

I will write down one for this idea 🙂

EDIT: Added:

> <https://github.com/defold/defold/issues/6405>
>
> Background topic on forum: https://forum.defold.com/t/tilemap-collisions-not-wor…king-when-layer-is-invisible/64653
> 
> Problem:
> When one is using two layers for game - one to represent collisions (often with basic shapes, like square or triangle) and one to represent visually the level (often with various shapes and edges), sometimes can happen, that visual representation layer is not covering the background collision layer, even if I set collision layer z under visual layer (mainly because of artistic vs practical aspects).
> Problem is, that even if we make collisions on separate layer, we can not switch its visibility, because collision shapes are then not respected by physics engine.
> 
> Workaround:
> To prevent this I can use different image(tilesource) for collision source and different for visual tiles. However for large maps/sources and in the development phase (when map can change a lot) this is cumbersome, as I always need to remember about eventually updating collision tilesource. Even though collision tiles are few, I can't make a smaller image for tilesource and reuse it for all visual representation, because the two tilesources (for collisions and visual representation) must have matching dimensions.
> 
> Idea:
> One solution would be to allow to disable visibility of a layer (e.g. collision layer), without affecting collision shapes. For now there is only one property for visibility for tilemaps layers: Visible
> 
> It would be great to \*\*add another boolean property here for tilemaps layers called for example: "Collisions"\*\*
> which if set to true, will tell physics engine to respect collision shape of the layer, regardless of property "Visible".
> 
> In this setup we could make a layer with collision shapes according to the tilesource, but the layer will not be visible in game ("Collisions": true, "Visible": false)
> 
> 
> P.S. Another helping solution would be to allow tilesources of different sizes to be in tilemap for collisions (but row size must be identical, so order is maintained).

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [February 14, 2025, 3:12pm UTC](https://forum.defold.com/t/tilemap-collisions-not-working-when-layer-is-invisible/64653/8 "2025-02-14T15:12:48Z")

</div>

Arh, I again come into this issue, was looking for the solution/issue and it was me who raised it 😅

Some time ago tilemaps collisions were worked on (when introducing rotated and flipped tilemap) - maybe you can now explain what data is taken into account when rendering and what into creating shapes?
