Minimum, smallest distance

Trace in all directions, set the Distance and the DeltaLocation for each direction (here 2 arrays) and then get the smallest value of the distance array and move into that direction.

The object should move in the direction closest to the wall. Unfortunately it didn’t work. How can I best implement this:

Thanks in advance!

You’re tracing only once, you should trace 4 times. Once in each direction.

My take on this since there’s going to be as many ways as there are people; assumes a Pawn + Floating Pawn Movement comp for collision:

Image from Gyazo

Does not currently account for other actors when measuring distance. Can be easily filtered with channels, though.

Very Nice!

I’ll just add that if the walls are not moving, this can be run once rather than on Tick. No need to waste those precious cycles for trace looping. Depends on what’s needed, ofc.

And if you do not want to use sliding collision the pawn + movement comp offers but still need to stop short of reaching an obstacle, you can either calculate it from actor bounds or look into how Sweep works. That’s providing you do not have collision covered already.

Good luck with rest!