When instantiating an object inside of something, how can I move it to the outside of the object?

Alright, to be more specific I’ve been writing a formations system for a party of players. The problem arises when I click too close to an obstacle, and one of the markers for the formation clips inside of an object like so:

marker

So basically what I need to happen is if these markers clip into an object, I need them to adjust themselves so they’re outside the object. I’ve wrote several scripts myself, using raycasts to detect collisions, and then adjusting them each frame based on which rays are touching the object. However these don’t work within one frame. Ideally i’d like to be able to make this happen within one frame so that as soon as I click, my characters get the updated locations of the markers, rather than their original locations. Any suggestions on where I should start?

Does it help any to use a Physics.SphereCast at the target location first? Then use one of the contact points to determine the direction and length that we must move the target location before restarting the process until we find a clear spot?

If you assign a very large radius to the sphere you can define a quiet a bit of clearance, but it will probably take longer to find a clear spot.