How to i access mesh instance of a specific location from gridmap??

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By God Of Theory

I created a mesh library and also a gridmap to place the mesh procedurally using code.
Now,I want to loop through all the mesh instance in my scene and edit their properties using code seperately.
Btw,get_meshes() is not what i want,because it returns the mesh and the transformation,not the individual created objects.

As an alternative,is it better to abandon using gridmap and use mesh instancing manually instead?

And also how do I let user interact with meshes in mesh library in grid map?
Ive tried using signal,but it doesnt seem to work in gridmap.

:bust_in_silhouette: Reply From: Zylann

GridMap does not really create individual MeshInstance nodes, you won’t be able to loop through them all in this way. What GridMap allows is only to change their orientation by 90 degree steps, change wich one is placed in each cell, and show or hide them.
You can modify the meshes it uses, but that will apply to every usage of the said mesh within the gridmap, because it’s not individual tiles, they are re-used and batched.

If you want to arrange meshes in a grid AND modify them individually at runtime, you should make the grid yourself either with MeshInstance or MultiMesh.

And also how do I let user interact with meshes in mesh library in grid map?
Ive tried using signal,but it doesnt seem to work in gridmap.

Blocks of a GridMap can have collision shapes, when you make the mesh library. However, you won’t be able to tell “this collision occurred with this particular node”, because again, GridMap doesn’t create nodes. However, (like TileMap in 2D), you may be able to tell which grid position you collided with, using world_to_map: GridMap — Godot Engine (stable) documentation in English
This then lets you call get_cell to find out which type of block you collided with. get_cell returns an ID which you can use in most MeshLibrary functions: MeshLibrary — Godot Engine (stable) documentation in English