Checking for Custom Trace Channel in C++

Basically you pass in the ECC_GameTraceChannel with the correct index 1 -18, those are the custom ones you defined in the editor

For instance


FHitResult ATracer::DoTrace(FVector start, FVector end) {
	FHitResult result;
	FCollisionQueryParams qp;		
	FCollisionResponseParams resp;
	GetWorld()->LineTraceSingleByChannel(result, start, end, ECollisionChannel::ECC_GameTraceChannel1, qp, resp);

	return result;
}

Would hit the first custom trace channel

Remember to set trace to block for the custom channel on the object that is supposed to be tested against.

1 Like