Tile detection with Area2D on a Topdown game

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

I am making a topdown game similar to stardew valley in the perspective, I have a tilemap which contains all the trees on the test level. I want to use a area2D with a circular collision shape to use the .overlaps_area function to see if any trees are nearby and if so I am going to turn the opacity down. Currently it wont detect any trees. I am pretty new and this is one of my first projects. Here is the current code I am trying to use…

var Trees = get_node(“/root/World/Tiles/Trees”)

if $Area2D.overlaps_area(Trees):

//I am using a variable to find the node since I could not plugin the node path directly

//into the if statement.

:bust_in_silhouette: Reply From: Aireek

I don’t think my previous comment showed up, I’ll rewrite it just in case. I don’t think you can do it like you are trying with var Trees = get_node(etc etc etc). I’m new as well and I believe that when tiles are added to a tilemap they are given an ID and that is what you need to detect for. I don’t have a specific answer BUT I do have a video of a gentleman adding “scenes” as tiles in a tileset. Which might honestly help you out even more than what you are trying. If not, he goes over the ID’s of a tile and how to find them (briefly). Also I enjoy this dude’s voice so much haha


njamaster’s answer mentions the ID’s i’m talking about. I hope you can find your answer through all this!

Aireek | 2020-04-16 09:22