Return tile when colliding with tilemap


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:

{ --[[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.



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.



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?

1 Like