How to use and what is the difference between get_overlapping_bodies VS get_overlapping_areas

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

I am trying to replicate the Super Mario Thwomp and I created a space where if the player is inside it activates the Thwomp descent. Because he falls before Mario goes under. When I try to get_overlapping_areas it doesn’t find Mario’s KinematicBody2D. Wish someone could explain to me the use of get_overlapping_areas and get_overlapping_bodies?
Below is an image with details.

enter image description here

:bust_in_silhouette: Reply From: kidscancode

get_overlapping_areas() detects other Area2Ds.

get_overlapping_bodies() detects PhysicsBody2D types (RigidBody2D, KinematicBody2D, or StaticBody2D).

Note that as stated in the Area2D documentation, the get_overlapping_* methods are only updated once per physics frame. It is typically preferable to use the area’s body_entered and/or area_entered signals.

This would be perfect for your situation. Mario entering the “Thwomp Scan Area” will trigger the body_entered signal and you can make the Thwomp fall.

Thanks for your response. I managed to solve the problem. I’m very grateful.

coderpy | 2019-08-02 00:54