Spawn something where a path exists

I’m making a 2D RPG. I currently use the A* pathfinding project for monsters in my game, and it works really well.

What I want to do is implement a delivery system like in EarthBound.

For this, what I need one big thing:

A way to figure out where the best place for the delivery guy to spawn is. He’ll spawn off screen (so outside of a certain radius), and he needs to have a viable path to the player. If no viable path exists, he’ll try another spot.

For this, I could either use some sort of algorithm to check from the player to different edges of the screen until a path is found (But I don’t know if the A* pathfinding project can check to see if a viable path exists in the first place)

Or I could check like, the 4 corners and 4 edges of the screen to see if there is a path, and if not, the delivery guy doesn’t spawn.

Any ideas?

Hi

The best approach is probably to check a bunch of random points using the IsPathPossible method.
See http://arongranberg.com/astar/docs/class_pathfinding_1_1_path_utilities.php#a25736e29fdb41bc3f1d57abeaf2c8eef

You can use Unity’s UnityEngine.Random.InsideUnitCircle to get a random point.