# setCollisionByProperty not working (the way I think it does)

**URL:** <https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642>\
**Category:** Phaser 3\
**Created:** [June 3, 2019, 1:45am UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642 "2019-06-03T01:45:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradydowling](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bradydowling/32/1146_2.png) [@bradydowling](https://phaser.discourse.group/u/bradydowling)\
**Post date:** [June 3, 2019, 1:45am UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642/1 "2019-06-03T01:45:38Z")

</div>

I’ve created [a test map with Tiled](https://github.com/bradydowling/super-mario-war/blob/master/src/assets/levels/map2.json) and I’m trying to get my character to collide with a layer on it [using setCollisionByProperty](https://github.com/bradydowling/super-mario-war/blob/master/src/scenes/gameplay.js#L108) but it’s never colliding (here’s [the game running](https://bradydowling.github.io/super-mario-war/)).

I think I’m doing something dumb/obvious but I’ve been toying with it for quite some time and can’t figure out what it is. My only guess is that there needs to be a certain order to when I set collision properties or make layers/sprites but I haven’t found an order that works yet.

I also noticed that the debug shading for the collision layer doesn’t show up at all so it seems like the layer isn’t being shown as collidable at all. I can’t tell why that’s the case though.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [June 3, 2019, 5:40pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642/2 "2019-06-03T17:40:31Z")

</div>

I think the tiles are missing the `collides` property (or any property). In Tiled, make sure you’re editing custom properties of a **Tile** , not **Tile Layer**.

This will also work:

```
this.collidesLayer.setCollision([1842, 1843, 1843, 1843, 1843, 1843, 1843, 1843, 1843, 1844, 2085, 2086, 2087, 2088, 2186, 2187, 2187, 2187, 2187, 2187, 2187, 2187, 2187, 2188, 2189, 2190, 2190, 2190, 2190, 2190, 2190, 2193, 2194, 2196]);
```

---

<div class="post-metadata">

**Author:** ![bradydowling](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bradydowling/32/1146_2.png) [@bradydowling](https://phaser.discourse.group/u/bradydowling)\
**Post date:** [June 3, 2019, 6:50pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642/3 "2019-06-03T18:50:45Z")

</div>

> [@samme](#):
>
> In Tiled, make sure you’re editing custom properties of a **Tile** , not **Tile Layer**

I think this is the key here. I have no idea how to edit properties of just the tile, not the whole layer. I guess I’ll go ahead and dig through Tiled documentation for it.

How did you get the following indices? I’m guessing you did it using something generated (from Tiled) but I’m not certain.

```javascript
this.collidesLayer.setCollision([1842, 1843, 1843, 1843, 1843, 1843, 1843, 1843, 1843, 1844, 2085, 2086, 2087, 2088, 2186, 2187, 2187, 2187, 2187, 2187, 2187, 2187, 2187, 2188, 2189, 2190, 2190, 2190, 2190, 2190, 2190, 2193, 2194, 2196]);

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [June 3, 2019, 8:24pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642/4 "2019-06-03T20:24:15Z")

</div>

In Tiled, you can click on a tileset tile (not a map tile) and then edit properties.

I found the tile indices in the JSON data, but see [Show tile indexes (v3)](https://phaser.discourse.group/t/show-tile-indexes-v3/1770).

---

<div class="post-metadata">

**Author:** ![bradydowling](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/bradydowling/32/1146_2.png) [@bradydowling](https://phaser.discourse.group/u/bradydowling)\
**Post date:** [June 3, 2019, 8:29pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-not-working-the-way-i-think-it-does/2642/5 "2019-06-03T20:29:04Z")

</div>

Wow, didn’t realize I’d have to do this in the tileset itself, amazing! Once I clicked on the good old wrench paper, the tileset editor showed up and I could select different tiles and apply properties to each of those tileset tiles. I _never_ would have found that without your help. Thank you! 🙏

![42%20PM](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/6/612542fe3c4d9757e957a08cdaef3d7ac7c6eabb.png)
