How Do I Get MultiSphereTraceByChannel In C++

As it says above. I’m moving a lot of my blueprints over to code and have come to this point. This is the Blueprint Node I’m trying to replicate in C++.

126265-temp.jpg

I needed to make a custom trace channel to make sure it registered all of the objects that it hits. Anyway, I know how to make a normal line trace and multi-line trace but I need some sort of Shape Trace Ideally a sphere. Im looking for what would be.

GetWorld()->SphereTraceMultiByChannel();

Any Suggestions / Solutions?

I found this answer but it’s for a single channel not a multi-channel and i can’t really make much sense of it if anyone else can, How to make a Sphere Trace - C++ - Epic Developer Community Forums

What you want is SweepMultiByChannel which allows you to specify a start and end point, along with a shape.

So your code for a sphere based shape would look something like this:

FCollisionShape MySphere = FCollisionShape::MakeSphere(500.0f); // 5M Radius
TArray<FHitResults> OutResults;
GetWorld()->SweepMultiByChannel(OutResults, SweepStart, SweepEnd, FQuat::Identity, TraceChannel, MySphere);
2 Likes

Thanks, it works great I spent some time figuring out how to use my custom trace channel but it’s all good now, cheers.

watch this. How To Do Line Tracing Using C++ In Unreal Engine - YouTube