GameMaker tilemap_tileset doesnt work properly

JAG

Member
I was just going to post saying it doesnt work at all, but Ive found a workaround.

I was originally trying to call tilemap_tileset on a tile layer with no set tileset. This doesnt work because GM apparently thinks this tile layer doesn't exist, so can't find it. So to make it work I just set an empty placeholder tileset in the tile layer and now the function works!

Just FYI in case anyone has this issue...
 
K

kevins_office

Guest
If you are adding tiles by code, you do not need to use a tile layer. You can add any type of item to any type of layer with code.
I make an empty instance layer with no place holders. I place tilemaps on that layer with code using layer_tilemap_create().
Then i can just add tiles to the tilemap with tilemap_set().
 
  • Like
Reactions: JAG

JAG

Member
@kevins_office cool yeah that makes sense. My usecase might be a little different, my rooms are getting sufficiently complex that I am getting a lot of value from having the resource view be the source of truth for what layers exist and at what depths. But I could def see generating the tilemap programatically in a project with a different structure. Thanks!
 
K

kevins_office

Guest
I am getting a lot of value from having the resource view be the source of truth for what layers exist and at what depths.
Yes, i do that also. I create the layer in the IDE as instance layer, name it in the IDE and set the depth, but just leave the layer empty in the IDE.
Then in code i add the tilemaps to that layer which was created in the IDE as instance layer.
 
  • Like
Reactions: JAG
Top