0 votes

Hi, i have an area that will apply some velocity to other areas inside. For example the wind effect.
I'm trying with areaentered, and areaexited 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

in Engine by (92 points)

2 Answers

0 votes
Best answer

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

by (92 points)
+1 vote

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)
    

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
by (4,005 points)

You are right, I can use getoverlappingareas, 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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.