Is it possible to get a tile from a created collection? (SOLVED)

Let’s assume two collections: game and level. Game collection has a factory to create a level collection, that has a tilemap inside.
Is it possible somehow to use tilemap.get_tile() to get a tile from a tilemap that is in a collection created by factory?

Because, when I try to use tilemap.get_tile(url_to_a_tilemap_in_created_collection, ...) I have an error:

ERROR:SCRIPT: /modules/platformer.lua:430: function called can only access instances within the same collection.

(There could be different level’s collection with different tilemaps loaded, but in game collection there are a player and many common game objects, so that’s why I’ve chosen such hierarchy)

1 Like

You should be able to get there tile from a script component in the game collection if the collection factory is in the same collection. Are your sure the function call happens from the game collection?

2 Likes

Ok, indeed, it is possible, thank to your hint I checked the url again and it came out I was using incorrect url of a collection, that wasn’t created in game collection :confused: Consider the case solved! :slight_smile:

2 Likes

It’s just can’t stop to amaze me how many times I’m searching for a solution to a problem and it turns out that it was not anyone else, but me who asked about it and even found a solution back then :smiley:

7 Likes