Hello everyone,
In my game, I'm having issues preventing sprites from being created inside of other objects. See GIF below:
media.giphy.com/media/XvlHzc1smlvYnVcMIp/giphy.gif
As you can see, it is sort of working, however, it always spawns the spring object to the right side of the boundary block.
Desired Behavior
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:
drive.google.com/file/d/1oCiQAQubzW8zhUA76W3if97-WbJtEGSQ/view
The function is called when the spring block is dropped, as seen below:
drive.google.com/file/d/1O_LsMLjv3ZgM39ChByiU-yKoVv535E9g/view
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:
drive.google.com/file/d/1kMXp6Wy_yRyBHVND22n3LgDcTqo1JmTA/view