Tilemap collisions not working when generated by a factory (DEF-3758) (SOLVED)


I want to create a tilemap in which its tiles are generated in runtime and in which the tilemap itself is generated in runtime by a factory. The problem is that if I try to generate a tilemap with the factory, the tilemap collisions don’t work, but if I try to instantiate the tilemap in the collection without using the factory, the collisions work.

Defold version: 1.2.145
OS: macOS 10.14.2
Link to a project to simulate this bug: https://mega.nz/#!yGR12aKC!BNsN_PJB89oqW7rxKMaSaZGaIOCHmKDOz1WGxSK2usc
There are two collection in this project that you can choose to run: factory.collection for testing the bug and instantiated.collection to demonstrate that the collisions work if the tilemap is not generated by a factory.


Yes, this does indeed look like a bug. I guess it is a combination of spawning the tilemap using a factory and then using set_tile() to populate the tilemap with tiles that causes the collision shape to not update properly. @Johan_Beck-Noren, @sven, @jhonny.goransson, can you confirm?

Attached project here:

Collision Bug.zip (70.9 KB)


Any update on this?


No, no update. We plan our next sprint (two weeks of work) tomorrow (Monday). We will evaluate and prioritise this issue during our planning session.


Created DEF-3758


Encountered similar issue (kinematic and dynamic collision objects interacting with static tilemap).
OS: Windows 10.
Defold: 1.2.146


  1. Allow kinematic/dynamic collision objects to reach steady-state on collision tile. (e.g. player or object landing on tile)
  2. set_tile() sets the tile to one not included in the collision mask.
  3. kinematic/dynamic object remains at rest.
  4. Initiating movement on the kinematic object recognizes updated collision mask, but only when the contact normal vector changes/is refreshed (verified through physics debug view).

e.g. moving away and then re-initiating contact with where the ghost tile is will respect the updated collision mask. Moving laterally to the ghost tile will cause the collision to persist.

IMHO this limits potential for using dynamic tilemaps during gameplay.


Released in Defold 1.2.147


@britzl downloaded 1.2.147 and reproduced my issue in post #6.
Post #6 highlights a more subtle issue and may need a new DEF- bug.

It refers to using a tilemap already instantiated in the main collection, and calling set_tile() to replace a collision mask tile with non-collision mask tile.

The collision mask does update, but the existing contact point normal vectors persist until the colliding object has been moved away.

i.e., set_tile() does not remove physics contact points.

I suspect the same bug may apply to factory-spawned tilemaps.


@jhonny.goransson, what are your thoughts on this?


Yeah hm, sounds like a different issue to me. I’ll take a look


Yes, it’s definitely a different issue because my issue is now fixed.


I managed to get a project for the issue that @0xfe was talking about. When a dynamic object collides with static tiles that are set up to collide with it and then the tiles are changed with others that shouldn’t collide with the object, the object remains still even if it should fall through. I also tried with a kinematic object with simulated physic from the platformer example, but it worked correctly for what I have tested.

Attached project here:

Collision bug 2.zip (51.1 KB)

To use the kinematic physic just change the collisionobject type to kinematic and check the use_kinematic property on hero script.