I cannot find a way to check a property of a tile.

Godot Version

4.2.2 Stable

Question

How do you find a way to check a custom property of a tile below, i setted up animated tiles in my tilemaps and also autotiles, i painted my terrain with the tool, but i have one tile with different property then the other ones;
Basically i wanna put a swimming animation when my character is in water:
When i start my project i see this error:
" Invalid call. Nonexistent function ‘local_to_map’ in base ‘Nil’ "

My script:
extends CharacterBody2D

@export var speed_multiplier: int = 15
@onready var animation_player = $AnimationPlayer
var idle_vector: Vector2 = velocity
@onready var tilemap = $“…/TileMap”
var tileset_name = tilemap.tile_set.tile_get_name(tilemap.get_cellv(tilemap.local_to_map(position)))

func _physics_process(delta):
tilemap.to_local()
tileset_name = tilemap.tile_set.tile_get_name(tilemap.get_cellv(tilemap.local_to_map(position)))
if Input.get_action_raw_strength(“left_shift”):
velocity = Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”) * delta * speed_multiplier * 100
velocity = velocity.normalized() * speed_multiplier * 2
else:
velocity = Input.get_vector(“ui_left”, “ui_right”, “ui_up”, “ui_down”) * delta * speed_multiplier * 35
velocity = velocity.normalized() * speed_multiplier
if velocity != Vector2.ZERO:
idle_vector = velocity
move_and_slide()

if velocity.length() != 0:
	if velocity.length() > 0:
		if velocity.length() < (speed_multiplier + 1):
			if velocity.x > 0:
				animation_player.play("walk_right")
			elif velocity.x < 0:
				animation_player.play("walk_left")
			elif velocity.y > 0:
				animation_player.play("walk_down")
			else:
				animation_player.play("walk_up")
		else:
			if velocity.x > 0:
				animation_player.play("run_right")
			elif velocity.x < 0:
				animation_player.play("run_left")
			elif velocity.y > 0:
				animation_player.play("run_down")
			else:
				animation_player.play("run_up")
else:
	if idle_vector.x > 0:
		animation_player.play("idle_right")
	elif idle_vector.x < 0:
		animation_player.play("idle_left")
	elif idle_vector.y > 0:
		animation_player.play("idle_down")
	else:
		animation_player.play("idle_up")
print(tileset_name)
@onready var tilemap = $“…/TileMap”
var tileset_name = tilemap.tile_set.tile_get_name(tilemap.get_cellv(tilemap.local_to_map(position)))

The variable tilemap becomes defined only after the node is attached to the tree (@onready)
The variable tileset_name is attempting to read the variable tilemap before it is ready. Ergo tilemap is null and you get the error.
You can move the definition of tileset_name to the _ready() function.

var tileset_name:String

func _ready()->void: 
    tileset_name = tilemap.tile_set.tile_get_name(tilemap.get_cellv(tilemap.local_to_map(position)))

PS: Use the code formatting button </> when posting code here.

I’m using 4.2 and “tile_get_name” looks like it has been removed, I get an error, and it isn’t in the documentation anymore.