Godot Version
4.5.1 Stable
Question
Basically, I have a scene (We’ll call it Scene A) that checks for custom data from a TileMapLayer. They’re both only instanced as children of the same node, but since Scene A is only spawned when it is needed and deleted after, I haven’t been able to directly connect them. While I could theoretically make a shitload of global variables, that sounds awful and definitely isn’t the right way to do it.
How do I get the custom data from the TileMapLayer into Scene A?
Inject a reference to TileMapLayer node into Scene A upon instantiation.
Okay, how would I do that?
Declare a TileMapLayer reference variable in Scene A’s script and assign the actual node reference to that, from the code that instantiates is.
Can you like, get an example for that? I still have no idea what you’re trying to say.
Scene A:
var tile_map_layer: TileMapLayer
script that instantiates Scene A:
var scene_a_instance = load("res://scene_a.tscn").instantiate()
scene_a_instance.tile_map_layer = %TileMapLayer # use the correct node path to TileMapLayer in your scene tree here
And instantiated Scene A will now have access to the tile map layer. It’s a standard, straightforward dependency injection pattern.
You say that, but it hasn’t worked. It still crashes on attempting to call the custom data.

var cell_data = tile_map_layer.get_cell_tile_data(cell_position).get_custom_data("Cell_Type")
Nevermind, figured it out. My cellposition check logic was broken, so it tried calling a position exactly 80 times larger than the cell’s actual position.