Tilemap Collider not working when created at runtime.

I originally created the tile map through the editor, and did all the set up (see picture “Working_Colliders”). This tile map has the collider gizmo show up in the editor, and I can see the outline of the tile map collider. My character can run and jump along the tiles, and all collision seems to work.

I wanted a larger tile map, and decided to break the world up into chunks, and have each chunk use it’s own tile map. I decided to do all of this through code so I can do procedural generation instead of doing everything by hand. I currently have 4 tile maps being generated, and each tile map is 32x32 tiles.

The set up through code is done in the attached image “Code”.

As you can see (Picture “Notworking_Colliders” attached) the collision set up looks identical. However, the collider does not show in the editor, and my character now falls through the world as well.

I’ve been trying to google and figure out what could be causing this, but I’m not coming up with much success. Would greatly appreciate any help!



6631291--756253--Code.PNG

Turns out I did a goof and was using the same variable to create the background tilemap. So ActiveLayer was being overwritten, and the other layer did not have colliders on them. So everything works now!