# Checking for Custom Trace Channel in C++

**URL:** <https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631>\
**Category:** C++\
**Tags:** unreal-engine, CPP, question\
**Created:** [October 9, 2022, 1:00pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631 "2022-10-09T13:00:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![xlman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xlman](https://forums.unrealengine.com/u/xlman)\
**Post date:** [October 9, 2022, 1:00pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/1 "2022-10-09T13:00:01Z")

</div>

Hi everyone,

I’m looking for away to check in C++ if the user entered the appropriate Custom Trace Channel name used in one of the classes. Is there a way to do that?

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [October 9, 2022, 1:20pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/2 "2022-10-09T13:20:06Z")

</div>

> [@Custom trace channel in c++?](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130):
>
> I created a custom trace channel from the collision tab in project settings. It may sound stupid but I have no idea how to use my new channel in c++: for example I want to do a single trace using my custom channel, how can I do it? (I mean, when it comes to specify the ECollisionChannel parameter)

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

```auto

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.

---

<div class="post-metadata">

**Author:** ![xlman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xlman](https://forums.unrealengine.com/u/xlman)\
**Post date:** [October 9, 2022, 2:58pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/3 "2022-10-09T14:58:58Z")

</div>

I’m using the ECC\_GameTraceChannel ofcourse. I just want to make sure the user is setting up himself with the correct name.

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [October 9, 2022, 3:31pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/4 "2022-10-09T15:31:18Z")

</div>

Then I guess you could try

> **[UCollisionProfile::ReturnContainerIndexFromChannelName](https://docs.unrealengine.com/5.0/en-US/API/Runtime/Engine/Engine/UCollisionProfile/ReturnContainerIndexFromChannelN-/)**
>
> Return index of Container index from DisplayName and vice versa this is misnamed now since I changed to update name if the name changed

---

<div class="post-metadata">

**Author:** ![IrSoil](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IrSoil](https://forums.unrealengine.com/u/IrSoil)\
**Post date:** [October 9, 2022, 10:41pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/5 "2022-10-09T22:41:09Z")

</div>

You can see binding between ECC\_GameTraceChannelX & in-editor names in your project’s `DefaultEngine.ini` . They looks like:

```auto
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Overlap,bTraceType=False,bStaticObject=False,Name="MyCustomCollisionChannelName")

```

Then you can just create a header with

```auto
#define ECC_MyCustomCollisionChannelName ECC_GameTraceChannel1

```

---

<div class="post-metadata">

**Author:** ![phil123456](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@phil123456](https://forums.unrealengine.com/u/phil123456)\
**Post date:** [September 25, 2025, 3:22pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/6 "2025-09-25T15:22:38Z")

</div>

how does this even answer the question ?

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [September 25, 2025, 9:13pm UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/7 "2025-09-25T21:13:36Z")

</div>

.h

```auto
// custom function to check channel name
public:
//#if WITH_EDITOR
	UFUNCTION(BlueprintCallable)
	bool CheckChannelCustom(FName NameToCheck);
//#endif

```

cpp

needed includes

```auto
#include "Engine/CollisionProfile.h"
#include "Engine/EngineTypes.h"
#include "Misc/ConfigCacheIni.h"

```

```auto

//#if WITH_EDITOR
bool ATraceActor::CheckChannelCustom(FName NameToCheck)
{	
	TArray<TSharedPtr<FName>> SharedNames;
	UCollisionProfile::GetProfileNames(SharedNames);		
	TArray<FString> OutMapList;
	
	const FConfigSection* MapListList = GConfig->GetSection(TEXT("/Script/Engine.CollisionProfile"), false, GEngineIni);
	if (MapListList)
	{
		for (FConfigSectionMap::TConstIterator It(*MapListList); It; ++It)
		{
			FName EntryType = It.Key();			
			FString EntryValue = It.Value().GetValue();			
			FString foundName = "";
			if (EntryValue.Contains("ECC_GameTraceChannel")) 
			{				
				FString startSearch = "Name=\"";
				FString endSearch = "\"";
				int32 startVal = EntryValue.Find(startSearch) + startSearch.Len();
				int32 endVal = EntryValue.Find(endSearch,ESearchCase::CaseSensitive,ESearchDir::FromStart,startVal);
				foundName = EntryValue.Mid(startVal, endVal - startVal);

				if (foundName == NameToCheck) {
					return true;
				}

// UE_LOG(LogTemp, Warning, TEXT(" foundName %s"), *foundName);
			};						
		}
	}	
	return false;
}
//#endif

```

---

<div class="post-metadata">

**Author:** ![jamaraala](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jamaraala](https://forums.unrealengine.com/u/jamaraala)\
**Post date:** [September 26, 2025, 1:30am UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/8 "2025-09-26T01:30:06Z")

</div>

Use GetcollisionResponseToChannal() In C++.

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [September 26, 2025, 8:20am UTC](https://forums.unrealengine.com/t/checking-for-custom-trace-channel-in-c/665631/9 "2025-09-26T08:20:41Z")

</div>

That will not check for a specific channel name.
