# setCollisionByProperty isnt working the way I believe it does

**URL:** <https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668>\
**Category:** Phaser 3\
**Created:** [May 9, 2022, 4:11pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668 "2022-05-09T16:11:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DylanDrechsel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/dylandrechsel/32/6504_2.png) [@DylanDrechsel](https://phaser.discourse.group/u/DylanDrechsel)\
**Post date:** [May 9, 2022, 4:11pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/1 "2022-05-09T16:11:01Z")

</div>

When I use “setCollisionByProperty” on a layer it doesnt change any of the collision keys on the tile objects. However if I use ‘forEachTile’ and set the keys to true myself it works. Is there something I am missing? Picture below shows my code and map.  
Thank you!

 ![Screenshot 2022-05-09 111341](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/b/b3d2293bbc254fb4b4ab960610bf1172bb1f60a7.png)

---

<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:** [May 9, 2022, 4:27pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/2 "2022-05-09T16:27:08Z")

</div>

👋

Add

```
console.log(tile.properties);

```

What do you see?

---

<div class="post-metadata">

**Author:** ![DylanDrechsel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/dylandrechsel/32/6504_2.png) [@DylanDrechsel](https://phaser.discourse.group/u/DylanDrechsel)\
**Post date:** [May 9, 2022, 4:56pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/3 "2022-05-09T16:56:24Z")

</div>

This is what is returned. There is nothing in properties.

 ![Screenshot 2022-05-09 125601](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/a/a273bb508a02f1e0d205b2ef5dadc0cf676d41e7.png)

---

<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:** [May 9, 2022, 5:10pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/4 "2022-05-09T17:10:09Z")

</div>

Did you set tile properties in Tiled?

---

<div class="post-metadata">

**Author:** ![DylanDrechsel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/dylandrechsel/32/6504_2.png) [@DylanDrechsel](https://phaser.discourse.group/u/DylanDrechsel)\
**Post date:** [May 9, 2022, 5:16pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/5 "2022-05-09T17:16:06Z")

</div>

No I didn’t the tutorial I followed didn’t mention it or I missed it. Here is how my TIled looks right now.

I am assuming I have to add “canCollide” into custom properties? Are there any other custom properties I should add while I am doing this?

When ever I add anything to custom properties it appears in the properties in layer. tile → layer → properties

 ![Screenshot 2022-05-09 131529](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/d/da0770cd6d2cd7d249a41cdcf7b4549126f5499c.png)

---

<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:** [May 9, 2022, 6:02pm UTC](https://phaser.discourse.group/t/setcollisionbyproperty-isnt-working-the-way-i-believe-it-does/11668/6 "2022-05-09T18:02:53Z")

</div>

I think you select a tile in the tileset panel first.

You can assign any property as long you use the same in your code.
