Tick area inside other area

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

Hi, i have an area that will apply some velocity to other areas inside. For example the wind effect.
I’m trying with area_entered, and area_exited signals from area, i add to some array and then in the process i apply this velocity. but i have a problem.
enter image description here

As you can see, when enters, prints inside and start moving, but when is full inside and collides with the other side of the area, it prints exited. I need to know what items are inside this area to apply the velocity each frame.

Here is the code:
enter image description here

:bust_in_silhouette: Reply From: Dlean Jeans

First is the answer to your question:

  • Use get_overlapping_areas() / get_overlapping_bodies() so you don’t need area_entered and area_exited
  • Make sure you change the collision_layer and collision_mask in the Inspector accordingly so the area only detects the player
  • Code:
    for area in $AirArea.get_overlapping_areas():
        _move_area(area, delta)


  • It seems that you have the Player scene as a Node2D with a Sprite and Area2D as children
  • That makes the Area2D move without moving the Sprite
  • So you should make the Player an Area2D with a Sprite as a child
    • Right-click on Area2D > Make Scene Root

You are right, I can use get_overlapping_areas, but this not solves my problem. It works with exactly same behavior, when my player area is full inside it stops. I found the solution, Check my answer for the solution if you are curious.

Raikish | 2019-03-05 15:25

:bust_in_silhouette: Reply From: Raikish

I found the solution in CollisionPolygon2D properties.
I don’t know why but, when I created the CollisionPoligon2D build mode was segments by default. I have 0 idea about how this works but, when I changed to Solids build mode it becomes to work as expected.
I will add a .GIF to show it.
enter image description here