I’m currently working on a vaporwave roguelite game, and there’s going to have items that can spawn from chests that can appear in specials rooms.
In order to get the items in chests, the player needs to manually open these.
Some of these items also spawn with a decorative pedestal (because they are unique/important). items that rests on pedestals are also kinematic. Also, every chests are resting on those pedestals.
So when I spawn items with pedestals, I need to make sure to place these items correctly so no pedestals overlapping.
Here are some sketches to help visualize this:
The green boxes represent a pedestal bounds. The dotted square is the bound of the newly spawned pedestal.
I do have C1 (the position of the chest’s pedestal) and A (the position of the activator, hence the player in this case)
So I need to get Cx while making sure that none of these bounds overlaps.
I do have some idea of how to do it, but I’m feeling like I’m missing something…
My guess is to get some kind of radius of each bound and simply get Cx by using the normalized direction made by subtracting A and C1 multiplied by each of those bounds radii.
But is there a better way to do it? The main grunge I have with this way is that I need to use square roots, and I kinda want to avoid that…