How to modify the triggering order of entering and exiting Area2D

Godot Version

4.3

Question

Hello everyone! I have a problem with Area2D, and I really can’t figure out how to solve it. Please help me
Run the program
A CharacterBody2D moves on two parallel Area2Ds A and B. When it leaves A and enters B, B’s “body_entered” will be triggered first, and then A’s “body_exited” will be triggered.
My original intention is to enlarge the cursor when the cursor enters the area, and play the cursor’s zoom animation when the cursor leaves the chess piece. But because of this triggering order, this function cannot be achieved when the cursor moves between two side-by-side chess pieces.
This triggering order seems to be related to the direction of cursor movement. When the cursor moves from A to B, and then from B to A, B’s exited is triggered first, and A’s entered is triggered.
It’s very strange, I don’t quite understand the principle.
Is there any good solution?

Try to use shape cast.

1 Like

I couldn’t really figure out what is going on in the image you shared but I assume there the body/object you are trying to detect overlaps both Areas at some point. The best option will be to have enough space between both Areas so that the object can safely exit the first one before entering the second one.

Another option I can think of is to wait for the exit signal from AreaA before performing the actions in AreaB’s entering signal.

It’s what you understand. Is there a way to listen for the end of the signal?
I have tried to reduce the size of the Area and increase their spacing, but it will cause other problems.

Thank you

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.