Converting collision channel to trace type query

Posted on Feb 18, 2024

UKismetSystemLibrary traces like SphereTraceSingle, BoxSphereSingle etc. take ETraceTypeQuery type to determine objects the trace should collide. This is counter intuitive for me since if you attempt to trace using UWorld sweep functions they take ECollisionChannel instead.

There is a class in the engine code, UEngineTypes. It has a function called ConvertToTraceType.

So to convert ECollisionChannel to ETraceTypeQuery simply call:

ETraceTypeQuery TypeQuery = UEngineTypes::ConvertToTraceType(ECC_WorldStatic);