Topic was automatically imported from the old Question2Answer platform.
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.
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.
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)
Second:
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.
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.