Daily Unreal Column #62 - UEngineTypes
Unreal Engine has multiple different ways of defining a collision parameters when tracing objects. Here is how to easily convert between each.
Unreal exposes two different APIs to execute traces. First one is part of the UWorld
type, allowing to write a code like this:
World->LineTraceSingleByChannel(..., ECC_WorldStatic, ...);
and the other one is via UKismetSystemLibrary
:
UKismetSystemLibrary::LineTraceSingle(...);
The main difference between them is that the version exposed in UWorld
takes collision channel type, which to some extent is human readable (e.g. ECC_WorldStatic
). On the other hand, the UKismetSystemLibrary
version is pretty much unreadable as it is just enumerated type starting with TraceTypeQuery1
, up to TraceTypeQuery32
.
This is where UEngineTypes
comes to the reascue as it allows you to convert a collision channel to a trace type query. Here is how:
ETraceTypeQuery TypeQuery = UEngineTypes::ConvertToTraceType(ECC_WorldStatic);