Character Body-Area2d collision detection outside overlapping

Godot Version



Hello! I am quite new to Godot and I have an issue with Area2D collision detection. Basically, What I want is when a player overlaps that tree, the tree becomes transparent, like in Stardew Valley. The mechanics works but I also get collision when the body of player is not overlapping the tree Area2D (first GIF) and also there is weird behaviour while overlapping (second GIF). This problem is intermittent, meaning it’s not always happening:




I actually found the solution. Please close this topic with status resolved. I cannot do it.

Hi there!

It would be awesome if you can share how you solved this, so that people searching for the same problem will find a solution.

Once you did that, feel free to click this icon on your own answer to mark it as the solution:


I had the player scene set on Autoload because I wanted to use it in Tree scene. Thus, I had another instance of player, behind the world tiles and I couldn’t see it. This instance was also interacting with tree’s area2Ds and consequently the behaviour in my topic.

In order to get the player characterbody2D in the tree scene I used Area2D.get_overlapping_bodies() method