How to collision check a tile underneath a tile?

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

Currently, i’m trying to make it so trees only generate under a GRASS tile.
Everything is being generated by a noisesimplex (you can check the code here; extends Node2Dvar noisevar map_size = Vector2(80, 60)var grass_cap = 0.5 - Pastebin.com )
I want it so it detects when a tree is NOT on grass and deletes itself.
How would I go by this?

:bust_in_silhouette: Reply From: njamster

Why don’t you simply do this?

if $Grass.get_cell(x,y) == 0:
    $Treee.set_cell(x,y, num)

As you generate the grass_map before the tree_map and they share the same map_size, all you have to do is check the value of the cell in the grass map before placing a tree in the tree map there. No need for a “collision check”.