How to write C++ equivalent of BP 'Make Array '



I’m working towards converting the above BP into C++.
I’m still pretty new to C++ so I’m not sure how to call this function (LineTraceForObjectsSimple) properly.

The function declaration looks like this:

static bool LineTraceForObjectsSimple(
	UObject* WorldContextObject, 
	const FVector Start,
	const FVector End, 
	const TArray< TEnumAsByte<EObjectTypeQuery> > & ObjectTypes, 
	bool bTraceComplex, 
	EDrawDebugTrace::Type DrawDebugType, 
	FVector& HitLocation, 
	FVector& HitNormal, bool bIgnoreSelf);

I think I’ve figured out most of it except the part where I need to tell it to only trace for WorldStatic and WorldDynamic?

Thank you.

You create the array first then pass it in as a variable to the trace function.

TArray< TEnumAsByte<EObjectTypeQuery> > ObjectTypes;

Use LineTraceSingleByObjectType from the UWorld class. There, you can specify object types to query.

In example:

GetWorld()->LineTraceSingleByObjectType(OutHit, TraceStart, TraceEnd, FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic)), FCollisionQueryParams(TEXT("IKTrace"), false, this));