How to detect overlapping of an object that appears suddenly on the screen

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

Hello! I’m trying to detect when an Area2D X appears intersecting another Area2D Y . X is not entering or exiting Y, it is hidden and with set_monitorable(false) and suddenly became visible and with set_monitorable(true). It seems that get_overlapping_areas and overlaps_area only detect entering and exiting intersections, so I don’t know how to proceed.

:bust_in_silhouette: Reply From: Pomelo

get_overlaping_areas() should return a list of all the areas that share a collision layer and collision mask “match”. For what I understand it looks for the areas, only when called, so it wouldnt make sense that whatever happened before, affects it. Have you tried just calling the function after the area appears?

Edit: setting monitoring or monitored to either true or false shouldnt even matter I think (not sure) because it affects the detection of entering and exiting only to fire signals, not for the get_overlaping_areas()

:bust_in_silhouette: Reply From: Inces

I don’t tnik so, signals may have a problem with that, but not get_overlapping_areas()
Perhaps You are trying to check collision to early after changing monitoring. Just use call_deferred, or wait some arbitrary frames before checking overlap