# How to get collision/trace channel by name in c++?

**URL:** <https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684>\
**Category:** World Creation\
**Tags:** channel, unreal-engine, Physics, Collision, question, CPP\
**Created:** [April 1, 2017, 3:35pm UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684 "2017-04-01T15:35:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oakisnotree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@oakisnotree](https://forums.unrealengine.com/u/oakisnotree)\
**Post date:** [April 1, 2017, 3:35pm UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684/1 "2017-04-01T15:35:22Z")

</div>

I setup a custom collision/trace channel from the project’s collision settings and want to retrieve the corresponding ECollisionChannel value by name in c++. How do I do that?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d32f9af21](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d32f9af21](https://forums.unrealengine.com/u/anonymous_user_d32f9af21)\
**Post date:** [April 4, 2017, 5:13am UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684/2 "2017-04-04T05:13:42Z")

</div>

I think you will have to set up your own definition in your local file. Which means you have to know ahead which channel(s) you need (ECC\_GameTraceChannel1, ECC\_GameTraceChannel2, etc.)  
and set up some local variable. You could come up with some way choose at run time if needed I imagine, but you have to set up the names yourself.

Full answer is linked here:

> **[Custom trace channel in c++?](https://forums.unrealengine.com/questions/301936/custom-trace-channel-in-c.html)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![oakisnotree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@oakisnotree](https://forums.unrealengine.com/u/oakisnotree)\
**Post date:** [May 13, 2017, 5:17pm UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684/3 "2017-05-13T17:17:08Z")

</div>

This didn’t answer my question. so I didnt accept it. But I just wanted to let everybody know that I have found a new workflow, which made answering this question obsolete. I am now use the GameSettings class from UE and load the necessary data from there wherever I need it.

---

<div class="post-metadata">

**Author:** ![Dongeru](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dongeru](https://forums.unrealengine.com/u/Dongeru)\
**Post date:** [August 7, 2017, 9:52pm UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684/4 "2017-08-07T21:52:58Z")

</div>

Uh this should be marked as the answer. Unreal doesn’t expose the editor defined channel names in C++, so you need to define them manually as such:

![203880-da.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/8/3383a9341f09b55dad4f2406ae0ae866d514f265.png)

---

<div class="post-metadata">

**Author:** ![Wabo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wabo](https://forums.unrealengine.com/u/Wabo)\
**Post date:** [July 30, 2021, 3:59pm UTC](https://forums.unrealengine.com/t/how-to-get-collision-trace-channel-by-name-in-c/389684/5 "2021-07-30T15:59:31Z")

</div>

// Find the CollisionChannel that belongs to our custom Profile Name (Preset tab) set inside the Project Settings (Collision tab)  
ECollisionChannel CollisionChannel;  
FCollisionResponseParams ResponseParams;  
FName ProfileName = “MyCustomProfileNameSetInEditorProjectSettings”;

```
if (UCollisionProfile::GetChannelAndResponseParams(ProfileName, CollisionChannel, ResponseParams))
{
	// If our lookup was successful, we now have a Collision Channel to do stuff with.. :)
}
```
