Trouble understanding manual shape2D collide method

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

Hello, I’m trying to have an area detection that performs different things depending on which shapes the player is overlapping with. I have an Area2D node with two rectangle collision shapes (one blue and the other green) which as I understand combine into one for the general detection. When I connect the signal, the overlap triggers as expected when the player enters any of the shapes, but after that I want to manually check with which shapes the player is colliding and here is where I am completely lost.

I’m using the Shape2D.collide() method but either I am confused with what it does (something about overlaps/collisions maybe?) or I am filling it with wrong info (transforms being the main suspect) because it shows really weird things like that the player is colliding with the blue shape while being only inside the green one.

Screenshot of the main scene and the areas

HitArea

extends Area2D

onready var blueShape = $BlueShape
onready var greenShape = $GreenShape

func _ready():
	connect("body_entered", self, "on_body_overlap")

func on_body_overlap(body):
	var bodyCol = body.get_node("CollisionShape2D")
	var insideBlueShape = blueShape.shape.collide(self.transform, bodyCol.shape, body.transform)
	var insideGreenShape = greenShape.shape.collide(self.transform, bodyCol.shape, body.transform)
	
	print("--- Body overlap registered ---")
	print("Inside blue shape: " + str(insideBlueShape))
	print("Inside green shape: " + str(insideGreenShape))
	print("--- *** ---")

EDIT: Figured it out, it was the transform. I needed to check using the global one.