How to get a random GridMap tile of a specific type?

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

Hello! I need to get the translation of a random GridMap tile and store it into a variable.

get_cell_item() doesn’t work, because it only takes 3 arguments. Any way to achieve this? Thanks in advance!

Hmm. Well, if you can get a random tile from a tilemap, you can surely get a random Gridmap tile, but I haven’t dealt with Gridmaps before.

Snail0259 | 2021-07-09 20:29

:bust_in_silhouette: Reply From: Shawk

Would get_used_cells()[randi() % get_used_cells().size()] do what you need?