Capsule trace in C++. Function appears to not exist?


I’ve been using a lot of line traces in my code, using a UWorld object and functions such as LineTraceSingleByChannel.

However, for one instance I really need to use a capsule trace, but intellisense can’t find any function equivalent to this for capsule objects. I know it exists in Blueprint, but I have to use this in C++ because of how the code is structured. Where is this function located if not in the same place as the line traces, and why is it not in the same place?

Hey man, try using SweepSingleByChannel with FCollisionShape::Capsule

1 Like

For my current purposes this may work, but it isn’t quite the same thing as a trace.

Having said that, OverlapSingle appears to just be throwing compile errors at me, telling me the arguments are incorrect, though I can’t see what I’m doing wrong:

if (GetWorld()->OverlapSingle(result, GetActorLocation(), GetActorRotation(), ECollisionChannel::ECC_WorldStatic,GetCapsuleComponent()->GetCollisionShape(),FCollisionQueryParams::DefaultQueryParam))

EDIT: Managed to get the collision test working using OverlapBlockingTestByChannel, but that doesn’t return any hit information, which I need.

1 Like

Hey, look at my answer again. I did indeed post the wrong function, the new one has similar parameters though.

As for the parameters, I’d have to see which one specifically is giving you errors.

At a “quick” glance, it all looks fine.

Just checking to see if you’d tried the new method I posted. I’m about to have to leave for work and didn’t wanna leave you hanging.

Sorry, yes, that appears to work. Seems odd that it has a different naming convention to the line traces, but at least it exists. It’s doing exactly what I need it to now, thanks!