In my game, I'm having issues preventing sprites from being created inside of other objects. See GIF below:
As you can see, it is sort of working, however, it always spawns the spring object to the right side of the boundary block.
When the player drops the spring block (called spr_uiSpring in project) I want it to test if it is overlapping the red boundary box (called spr_boundaryBox in project). If it is, I want to automatically move the spring block to the left or right side of the boundary box, depending on whichever side the spring block is closest to when it is dropped.
I'm testing the angle of the spring block to the boundary block and then comparing the angle in a function, as seen below:
The function is called when the spring block is dropped, as seen below:
Once the spring block has been dropped in the correct place, is creates a spring, as seen in the GIF above. I don't want the spring to spawn inside of the red boundary block.
I may be doing this a really dumb way. If anyone has any recommendations on how to fix my logic, or provide an alternative way to achieve my desired behavior, I would really appreciate it. Here is a link to the entire project file: