how can i make an area to hit one body/area at the same time? i don't want to collide two objects at the same time.

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

hello. i’m using godot 3, and got a problem, i want to make “breakout” game. but there’s a problem. paddle have 3 area2d, one for left, one for right, one for middle. i want ball to do something else when he collides with one of these. i did it but there’s a problem, some times ball hit them in the same time, and codes for two different area2d’s happen. how can i fix this? i want it to when it hits 2 area2d at the same one of their code happen, a random one of them, or the area2d’s has more collision area.
game files: https://ufile.io/tut86

Looks like I have similar problem as you. My topic here Can I manipulate signals execution order when I enter two diffrent Areas2D at once - Archive - Godot Forum (still unanswered).

For your case you can try to add some bool flags. For example:
make bool left_area_entered = false
in on_body_entered() from left_area set left_area_entered to true (and to false on_body_exited()), and then in your center area on_body_entered() start the code with
if ! left_area_entered:
your_code()

Make same for other areas, and now only one area can be processed at once (randomly)

Rawas | 2018-12-19 10:44