Given, that there is much more "good" area than "bad" ("good" is the place when it is ok to place a character, and bad is eg. inside a wall), You could do the following:1.) Generate a random place.2.) Check whether the line on the given place, parallel with the Y axis intersects a "good" or "bad" place.3.) If it intersects a "good" place, You can spawn your character, but if it is a "bad" place, then goto "1.)"Also, You can then check the distance of the nearest edge with the function You made, and if it is less then the radius of the character, then it is fully ok, to spawn it.Or at least this is how I'd get started.