Keeping track of indefinite number of node instances

Godot Version

Godot 4.3

I’m trying to create a City builder/CoC-type game. I’ve created a tilemap layer and spawnable building that can be repositioned on the tilemap layer. I need to keep the position data of each instance of building in an array, but I’m stuck at a point where, if I click on a building out of many instances of building, how do I know which instance refers to the particular building-instance’s position-data in the array to update the position.
Note: I cannot rename each instance, as there could be any number of instances.

When you click on the building, you can get a reference to the building you clicked. You can then find that reference in your array.

1 Like