How do i make a list of all bodies that are in area 2d

Godot Version

4.3

Question

at the moment i am trying to write a script where all bodys that get into an area 2d are noted in a list, for example in an array. it is important that i am able to access the whole node so that i can later apply velocity to the note. does anyone have an idea how i can do this? as this is the basis for my project i have nothing to show here yet.

Have you found this answer on repelling objects away form a area2D when the objects are inside it by mrcdk?

Here’s the relevant documentation on get_overlapping_areas and get_overlapping_bodies Area2D — Godot Engine (stable) documentation in English

1 Like

When the body enters the area, append it to array. When it leaves, remove is from the array.

Loop through the array to apply velocity to each of the bodies.

1 Like