Repeating the same BoxTrace until it doesn't have a hit result.

Recently, while rewriting a procedural generation method I used a while back (I unfortunately lost it due to a computer crash), I have been struggling to “retry” the box trace until it isn’t overlapping a certain actor. I appreciate the help I can get for this, thanks in advance. :slight_smile:

For a more detailed explanation of what I’m doing with this:
*A for loop runs a certain amount of times, each loop ABSOLUTELY HAS TO SPAWN AN OBJECT.
*On each of the for loops, a Box Trace for objects is preformed and returns whether or not it has returned a specified object and prints if it did hit or not.
*Wherein is where the problem lies is once the box trace has a hit result, it needs to repeat itself until it no longer overlaps any of the specified object types.

The main thing I’m looking for is how to loop the box trace until it has no hit result from the aforementioned types; just trying to introduce clarity to this topic.

So, hooking up the hit result returning a true value works but only a few times. The other times, it causes an infinite loop and breaks the program. Is there any way around this?

A recursive function.

Ah, of course. Thanks for the refresher! Only problem is I have trouble comprehending recursion when it comes to traces. Would a while loop connected to the out hit result and set as a variable work to make it recursive or stay an infinite loop?

The attached image shows the for loop and the hit result connects to a branch which spawns an actor whether or not the hit happens. Should I nest the while loop in the for loop, if it is the correct operation to perform?

Nevermind, I came up with a method that works flawlessly now. Simplistic answer, I should’ve just remembered recursion. :rolleyes: But man, do I feel kinda stupid. Thank you, MostHost LA! :smiley:

One problem has arisen, sometimes objects will still overlap when they spawn. How should I go about moving their location out of the intersecting object? Spawn collision handles do not seem to help. Judging by what I’ve seen from the trace, there is a hit and a new trace is performed however, it doesn’t spawn the object there. Any ideas?