LineTraceMultiByChannel - Overlap until Hit - How To?

Hi,

Is there a equivalent of LineTraceMultiByChannel but where the overlap list stop when a “block” occured?

My goal is to retrieve the list of overlap between a point A and B and stop the process once a Block happen.

As of today, LineTraceMultiByChannel will list all Overlaping object and my “block” object but some Overlap item are behind the Block Object.
The only way to use this list is to sort / compare the “time” link to each HitResult and check that it happenned before the “block”.
In term of efficiency, I bet there is an alternative way.

Any proposal?

Thanks,

LineTraceSingleByChannel should be what you want. It returns the first blocking hit only (if found).

It’s not what I’m looking for.
I need the list of Overlap until the Blocking hit.
I may do 2 traces or sort the LineTraceMultiByChannel by time, but I was wondering if something more efficient was already implemented.

thanks,

According to the comments in the code, the blocking hit will always be the last element in the array returned by LineTraceMultiByChannel:

So, if you aren’t seeing that behavior that would be a bug.

This is what I thought initially, but if you read carefully, it never say that the Overlapping Hit will be constraint by the blocking hit.
So you have ALL the overlapping hit in your trace distance and also the position of the first blocking hit but there is no relation between Overlapping hits and Blocking hit. That’s confuse me at first glance.

Yea, I wouldn’t expect there to be information relative to the blocking hit vs the overlapping shapes. If you need the overlapping shapes sorted, then you just have to do that manually it seems - which isn’t the end of the world. I’d definitely lean towards just sorting the list than doing a 2nd raycast. If you use the Array::Sort method with a custom predicate - it’ll be quick (it automatically does a QuickSort if the element count is above 8, otherwise it defaults to BubbleSort).

Why dont you try sorting the results by distance? Surely the “only” blocking hit should be the furthest?

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/FHitResult/index.html

SOrting by distance / time is not an issue.

I was just asking the community if there was something built-in that is optimized for this type of request. Just because, if you are doing a long distance trace, you can have to sort hundred objects while your blocking hit is near to you.

Thanks for your answer and I will implement the sort on time in my code!