# Return tile when colliding with tilemap

**URL:** <https://forum.defold.com/t/return-tile-when-colliding-with-tilemap/64393>\
**Category:** Feature requests (USE GITHUB)\
**Created:** [February 5, 2020, 9:49am UTC](https://forum.defold.com/t/return-tile-when-colliding-with-tilemap/64393 "2020-02-05T09:49:48Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [February 5, 2020, 9:49am UTC](https://forum.defold.com/t/return-tile-when-colliding-with-tilemap/64393/1 "2020-02-05T09:49:48Z")

</div>

When a collision object is colliding with a tilemap, it would be handy to get the tile x,y in the collision response, in addition to this:

```
DEBUG:SCRIPT: 
{ --[[0x111b7da60]]
  normal = vmath.vector3(0.74852848052979, -0.66310274600983, 0),
  position = vmath.vector3(95.643836975098, 159.35762023926, 0),
  other_position = vmath.vector3(0, 0, 0),
  own_group = hash: [player],
  relative_velocity = vmath.vector3(0, 0, 0),
  other_group = hash: [spike],
  other_id = hash: [/terrain],
  other_mass = 0,
  group = hash: [spike],
  applied_impulse = 0,
  distance = 0.59447586536407,
  life_time = 0,
  mass = 0
}

```

This would help creating destructible terrain or to determine whether a tile will harm the player or not.

---

<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:** [February 10, 2020, 9:58pm UTC](https://forum.defold.com/t/return-tile-when-colliding-with-tilemap/64393/2 "2020-02-10T21:58:59Z")

</div>

I second this. I’ve had problems with this in the past. Using math.ceil / math.floor to convert floating points to integers In an attempt target the exact tile the player touches is _not_ as simple as it sounds.

---

<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 11, 2020, 4:43am UTC](https://forum.defold.com/t/return-tile-when-colliding-with-tilemap/64393/3 "2020-02-11T04:43:51Z")

</div>

> [@totebo](#):
>
> When a collision object is colliding with a tilemap, it would be handy to get the tile x,y in the collision response

Yes that would be handy but we do not have this information more readily available than you do. Chunks of tiles from the tilemap gets combined into large convex shapes and passed to Box2d. @JCash do you see any way for us to calculate this in the engine when a collision happens?
