# How do I use GetHitResultUnderCursorByChannel in C++?

**URL:** <https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269>\
**Category:** Cinematics & Media\
**Tags:** Trace, visibility, unreal-engine, question\
**Created:** [May 26, 2014, 1:00pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269 "2014-05-26T13:00:16Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kochab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kochab](https://forums.unrealengine.com/u/Kochab)\
**Post date:** [May 26, 2014, 1:00pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/1 "2014-05-26T13:00:16Z")

</div>

In my blueprint GetHitResultUnderCursorByChannel node I have the trace type set to “Visibility.” The function takes an ETraceTypeQuery that I’m not sure how to set in C++.

---

<div class="post-metadata">

**Author:** ![Uninventive](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Uninventive](https://forums.unrealengine.com/u/Uninventive)\
**Post date:** [July 17, 2014, 8:52pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/2 "2014-07-17T20:52:04Z")

</div>

I echo this question. It looks like GetHitResultUnderCursor has been deprecated, but the …ByChannel function’s first argument is ETraceTypeQuery. The doc for that enum just lists by the queries by number ([ETraceTypeQuery | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/ETraceTypeQuery/index.html)).

What does ETraceTypeQuery do?

---

<div class="post-metadata">

**Author:** ![Kochab](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kochab](https://forums.unrealengine.com/u/Kochab)\
**Post date:** [July 17, 2014, 9:58pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/3 "2014-07-17T21:58:36Z")

</div>

Yeah that’s kind of what I was wondering myself. There is no TTQ\_Visibility, there is only TraceTypeQuery1 [2,3,4…] so how do you know which one is visibility and which ones are your custom ones that you set in the editor? Hopefully, someone can elaborate on the use of these queries.

---

<div class="post-metadata">

**Author:** ![Snipe3000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Snipe3000](https://forums.unrealengine.com/u/Snipe3000)\
**Post date:** [July 18, 2014, 3:50pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/4 "2014-07-18T15:50:20Z")

</div>

I’m also trying to figure out how to use this function. I’ve been trying to setup a top-down, mouse aiming character controller in c++, and I think this is the key to getting it to work.

---

<div class="post-metadata">

**Author:** ![watkinzez\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@watkinzez\_1](https://forums.unrealengine.com/u/watkinzez_1)\
**Post date:** [August 27, 2014, 1:21am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/5 "2014-08-27T01:21:45Z")

</div>

This bugged me for ages, so I just did it in blueprints, but I stumbled across how to do it yesterday!

GetHitResultUnderCursorByChannel(UEngineTypes::ConvertToTraceType(ECC\_Camera), true, Result);

That’s converting a collision channel to a trace channel; you could also convert ECC\_Visibility, or any other channels you’ve defined.

---

<div class="post-metadata">

**Author:** ![Stormsson](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Stormsson](https://forums.unrealengine.com/u/Stormsson)\
**Post date:** [April 4, 2018, 8:49pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/6 "2018-04-04T20:49:15Z")

</div>

after almost 4 years, thank you

---

<div class="post-metadata">

**Author:** ![DenKuzn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DenKuzn](https://forums.unrealengine.com/u/DenKuzn)\
**Post date:** [April 25, 2019, 8:59am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/7 "2019-04-25T08:59:52Z")

</div>

after almost 5 years, thank you so much

---

<div class="post-metadata">

**Author:** ![Pelogetan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Pelogetan](https://forums.unrealengine.com/u/Pelogetan)\
**Post date:** [September 24, 2020, 8:39am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/8 "2020-09-24T08:39:53Z")

</div>

after almost 6 years, thank you so many much!

---

<div class="post-metadata">

**Author:** ![knifeoffwork](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@knifeoffwork](https://forums.unrealengine.com/u/knifeoffwork)\
**Post date:** [February 3, 2021, 6:29am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/9 "2021-02-03T06:29:47Z")

</div>

after almost 7 years, thank you so many much!

---

<div class="post-metadata">

**Author:** ![scottmcpherson99](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@scottmcpherson99](https://forums.unrealengine.com/u/scottmcpherson99)\
**Post date:** [February 10, 2022, 4:21pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/10 "2022-02-10T16:21:08Z")

</div>

after almost 8 years, thank you so very many much!

---

<div class="post-metadata">

**Author:** ![Screll3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Screll3](https://forums.unrealengine.com/u/Screll3)\
**Post date:** [August 4, 2022, 8:53am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/11 "2022-08-04T08:53:41Z")

</div>

after almost 9 years, thank you so very many much!

---

<div class="post-metadata">

**Author:** ![123pirke](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@123pirke](https://forums.unrealengine.com/u/123pirke)\
**Post date:** [September 18, 2022, 3:14pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/12 "2022-09-18T15:14:58Z")

</div>

The funny thing is, when looking at the source code of PlayerController, the ByChannel call in the end converts the TraceType back to CollisionChannel:

```auto
bool APlayerController::GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const ETraceTypeQuery TraceChannel, bool bTraceComplex, FHitResult& HitResult) const
{
	return GetHitResultAtScreenPosition( ScreenPosition, UEngineTypes::ConvertToCollisionChannel( TraceChannel ), bTraceComplex, HitResult );
}

```

So I wonder why the original implementation has been marked deprecated and the new stuff still does the same 9 years later…

---

<div class="post-metadata">

**Author:** ![eldany.uy](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eldany.uy/32/821920_2.png) [@eldany.uy](https://forums.unrealengine.com/u/eldany.uy)\
**Post date:** [November 21, 2023, 2:49pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/13 "2023-11-21T14:49:44Z")

</div>

after almost 10 years, thank you so very many much!

this thread can’t die!

---

<div class="post-metadata">

**Author:** ![GarbaGod](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@GarbaGod](https://forums.unrealengine.com/u/GarbaGod)\
**Post date:** [December 14, 2023, 4:04am UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/14 "2023-12-14T04:04:26Z")

</div>

after almost 11 years, thank you so very many much!

literally 1 year after from last post

---

<div class="post-metadata">

**Author:** ![VarXael](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@VarXael](https://forums.unrealengine.com/u/VarXael)\
**Post date:** [October 1, 2024, 5:16pm UTC](https://forums.unrealengine.com/t/how-do-i-use-gethitresultundercursorbychannel-in-c/284269/15 "2024-10-01T17:16:34Z")

</div>

Huello, 12 years later, couldnt wait till december to make it exactly an year woops

Anyways, thank you so much little helper from the past 🙂
