Hey all,
I have a building game and am currently limiting where the player can place an object based on a "CanBuild" boolean that is set when the mouse_ entered/exited signals from an area2D on the previously placed objects.
I place the new object just outside the restricted area2D (so that "CanBuild" is true), the objects will have overlapping area2Ds, both detecting the mouse_ entered and exited states. The objects are instanced scenes for reference.
The problem is I can build on the first scene, then build over the second scene, then back to the first ad nauseum. If the two objects are placed far enough apart that there is not overlap, everything works as expected.
I believe that the mouse exited signal on the new scene is being called AFTER the mouse entered on the first scene, which of course is setting CanBuild to true despite still being within the area2D of the first scene.
I am not sure how to resolve this. As this is a mouse_entered signal and not an overlapping body, I can't build an array (can I?) - though potentially I could increment an int and keep count. I could also perhaps use a separate area2D to manage the build tolerance/detection, but it seems like an ugly solution.
Before I do anything like that, I wanted to check I wasn't missing a built in simple solution.
Cheers!