# Custom trace channel in c++?

**URL:** <https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130>\
**Category:** World Creation\
**Tags:** channel, trace-channels, unreal-engine, Physics, Collision, custom, CPP, question\
**Created:** [September 14, 2015, 10:42am UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130 "2015-09-14T10:42:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sneppy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sneppy](https://forums.unrealengine.com/u/Sneppy)\
**Post date:** [September 14, 2015, 10:42am UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/1 "2015-09-14T10:42:55Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33e74471](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33e74471](https://forums.unrealengine.com/u/anonymous_user_33e74471)\
**Post date:** [September 14, 2015, 1:38pm UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/2 "2015-09-14T13:38:34Z")

</div>

They show up as ECC\_GameTraceChannel1, ECC\_GameTraceChannel2, etc. in C++. If you look in the EngineTypes.h file you can see this bit here, which tells you probably the best way to deal with it.

```
	// in order to use this custom channels
	// we recommend to define in your local file
	// - i.e. #define COLLISION_WEAPON ECC_GameTraceChannel1
	// and make sure you customize these it in INI file by
	// 
	// in DefaultEngine.ini
	//
	// [/Script/Engine.CollisionProfile]
	// GameTraceChannel1="Weapon"
	// 
	// also in the INI file, you can override collision profiles that are defined by simply redefining
	// note that Weapon isn't defined in the BaseEngine.ini file, but "Trigger" is defined in Engine
	// +Profiles=(Name="Trigger",CollisionEnabled=QueryOnly,ObjectTypeName=WorldDynamic, DefaultResponse=ECR_Overlap, CustomResponses=((Channel=Visibility, Response=ECR_Ignore), (Channel=Weapon, Response=ECR_Ignore)))

```

---

<div class="post-metadata">

**Author:** ![anon47348756](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon47348756](https://forums.unrealengine.com/u/anon47348756)\
**Post date:** [March 1, 2018, 10:26am UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/3 "2018-03-01T10:26:16Z")

</div>

**UE4 ver 4.17.2**

See DefaultEngine.ini in your Project. You will found what you named TraceChannel rows, likes below:  
(If you made new TraceChanel “Tracer01”, Search “Tracer01” in DefaultEngine.ini.)

```
DefaultChannelResponses=(Channel=ECC_GameTraceChannel2,Name="Tracer01",DefaultResponse=ECR_Block,bTraceType=True,bStaticObject=False)

```

ECC\_GameTraceChannel2 is “enum ECollisionChannel”. You have to change it to ETraceQueryType. Use UEngineTypes::ConvertToTraceType() for convert to ETraceQueryType from ECollisionChannel likes below:

```
ETraceQueryType MyTraceType = UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_GameTraceChannel2);

```

Then You should use MyTraceType to Trace Function( Ex: SphereTraceMulti() )

---

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [July 1, 2019, 6:31pm UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/4 "2019-07-01T18:31:48Z")

</div>

ETraceQueryType - 4.22: no such variable type ☹

---

<div class="post-metadata">

**Author:** ![der\_KruspeX](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@der\_KruspeX](https://forums.unrealengine.com/u/der_KruspeX)\
**Post date:** [January 10, 2021, 6:20pm UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/5 "2021-01-10T18:20:13Z")

</div>

It is `ETraceTypeQuery`

---

<div class="post-metadata">

**Author:** ![KKochiss](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KKochiss](https://forums.unrealengine.com/u/KKochiss)\
**Post date:** [August 16, 2021, 7:12pm UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/6 "2021-08-16T19:12:47Z")

</div>

In what file should you add:  
ETraceQueryType MyTraceType = UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC\_GameTraceChannel2);

In your project header file or just where you plan to use this?

---

<div class="post-metadata">

**Author:** ![Dherian97](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dherian97/32/88718_2.png) [@Dherian97](https://forums.unrealengine.com/u/Dherian97)\
**Post date:** [February 23, 2023, 4:27pm UTC](https://forums.unrealengine.com/t/custom-trace-channel-in-c/332130/7 "2023-02-23T16:27:34Z")

</div>

Thanks 4 this!
