Hi there,
Is there any method to do a line trace by channel, but trace for more than one channel at once?
In my case I would like to trace for the (custom) channels UIObject AND UsableObject. Any ideas?
Thank you!
Hi there,
Is there any method to do a line trace by channel, but trace for more than one channel at once?
In my case I would like to trace for the (custom) channels UIObject AND UsableObject. Any ideas?
Thank you!
Hello ,
I’m not quite sure if there is something already built in to do this directly but the first question would be what you’re looking to do with it. Do you wish for the trace to pick up anything that is UIObject or UsableObject or does it need to be classified as both for the trace to pick it up?
Try making 2 line traces, one after the another… I know it’s not exactly what you were expecting but this solution will work and is very performance cheap
Hi ,
it’s just to change the color of the crosshair, depending of the type of the object.
Ok, thanks. I will try that.
Try making 2 line traces, one after the another… I know it’s not exactly what you were expecting but this solution will work and is very performance cheap
The above ‘solution’ proposed does in fact work, but is not the correct answer, nor the most performant. His answer implies doing more traces for each channel, but imagine you’ve got an enemy tracing 5 times for 5 channels every frame, and then you spawn twenty of those. That is now 100 trace queries every frame. That is a pretty heavy load on the CPU and only goes up exponentially if you wanted to query more than 5 channels per enemy.
Looks like you’re asking for a solution for blueprints, but I am mostly using C++. If anyone else finds this, the correct way to do this in C++ is using SweepSingleByObjectType and passing a FCollisionObjectQueryParams struct with added channels you wish to query like so:
FHitResult groundHitResult;
FVector traceStart = the start of your trace
FVector traceEnd = the end of your trace
FCollisionShape colShape = FCollisionShape::LineShape();
FCollisionQueryParams traceParams;
FCollisionObjectQueryParams objParams;
GetWorld()->SweepSingleByObjectType(groundHitResult, traceStart, traceEnd, FQuat::Identity, objParams, colShape, traceParams);
Seems like a blueprint method for this should already exist, i’d try looking around for it.