Godot Version
4.2.2
Question
I have an isometric tileset set up in my game that I have added a Custom Data layer to (layer 0 called TileExits) to hold an integer representing the possible ‘exits’ from that tile - up right / down right / down left / up left or any combination.
I have been trying to access this custom data but I am encountering the following error
Attempt to call function ‘get_custom_data’ in base ‘null instance’ on a null instance.
which also shows the error
Player.gd:135 @ _get_tileData(): Parameter “version” is null.
So I am assuming that the null instance either means that the tile map itself hasn’t yet completed being ‘loaded’ (hence the call_deferred) or that my link to the tile map isn’t correct.
So, my code in regards to this is as follows:
@onready var tile_map: TileMap = $"../TileMapRedraw"
then in the ready function:
func _ready():
call_deferred("_get_tileData")
and lastly in the called function:
func _get_tileData():
var hoveredtile = tile_map.local_to_map(self.position)
var tile_data = tile_map.get_cell_tile_data(0, hoveredtile)
var tile-data2 = tile_data.get_custom_data("TileExits")
Can anyone tell me why I get the errors I get?
Oddly this was working successfully until I heavily edited the ‘TileMapRedraw’ tile set/settings. Would editing the TileMap break something once it’s been linked to?