Make a Spawn coin system avoiding spawning inside a actor

Hello all!

I have some kind of problem while I am trying to figure out this:

I have some coins that I want to spawn in my level. Like in the next illustration.

The blue squares represent obstacles which I need to avoid while spawning the coins in the level (Coins are represented by the yellow circles).

I add the coins by using “Add Child Component” node. Then I generate a random point in a “spawning area”. But sometimes the coins spawn inside an actor or in a way its colliding with it.
I want to avoid obstacles like shown in the illustration in a way, if it is an obstacle the coin will spawn next to the obstacle avoiding it.

I use following blueprint scheme to spawn coins:

One way is this:

Build the navigation mesh in the level. As you know the navigation mesh builds around obstacles. Building navigation should generate an object called “RecastNavMesh-Default”. You can use it to get locations on the navigation mesh.


The “Project point to navigation” node takes a point in space and a radius and returns a random point on the navigation mesh, inside the radius.

To make this node work, I think you also need to go to project settings > engine > navigation system > agents and add one agent.
I have something like this:

I am not sure if this last part is absolutely necessary for the node to work.