What would be the best way to get Tilemap Reference

Godot Version

Godot 4.2.1

Question

I’m trying to get it to where the player knows what tile it is on in a 2D top-down space, in order to then get what terrain that tile has, and I’m having trouble with trying to get a reference of the Tilemap “World”, which keeps getting returned as a null instance.

When get_node returns a null instance, that usually means the provided node path was wrong. How does your scene tree look like? What node in the tree is the script attached to, and where is your TileMap node located relative to it?

Screenshot 2024-04-25 151647

So if your script is attached to the Player node, you’d do: get_parent().get_node("World") or get_node("../World") for short

If you were already doing that, please post your whole script!

get_node(“…/World”) worked

1 Like