# Line trace by channel doesn't work in c++

**URL:** <https://forums.unrealengine.com/t/line-trace-by-channel-doesnt-work-in-c/391695>\
**Category:** C++\
**Tags:** line-trace, debug-trace, unreal-engine, CPP, Blueprint, question\
**Created:** [April 23, 2017, 3:24pm UTC](https://forums.unrealengine.com/t/line-trace-by-channel-doesnt-work-in-c/391695 "2017-04-23T15:24:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e530f8f01](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e530f8f01](https://forums.unrealengine.com/u/anonymous_user_e530f8f01)\
**Post date:** [April 23, 2017, 3:24pm UTC](https://forums.unrealengine.com/t/line-trace-by-channel-doesnt-work-in-c/391695/1 "2017-04-23T15:24:19Z")

</div>

Hello guys,  
My code to create a line trace and hit the landscape doent’s work, while the same thing in blueprint works.  
Can anyone help me?

```
	FHitResult result_private;

	UKismetSystemLibrary::LineTraceSingle_NEW(GetWorld(), FVector(0.0f, 0.0f, -5000.0f), FVector(0.0f, 0.0f, 5000.0f), UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Visibility), true, ActorsToIgnore, EDrawDebugTrace::Persistent, result_private, true);

	GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Green, result_private.ImpactPoint.ToString());

```

---

<div class="post-metadata">

**Author:** ![SuryaPrakashModi](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SuryaPrakashModi](https://forums.unrealengine.com/u/SuryaPrakashModi)\
**Post date:** [May 25, 2021, 7:19am UTC](https://forums.unrealengine.com/t/line-trace-by-channel-doesnt-work-in-c/391695/2 "2021-05-25T07:19:49Z")

</div>

watch this. [How To Do Line Tracing Using C++ In Unreal Engine - YouTube](https://youtu.be/LWeQicz_teo)

---

<div class="post-metadata">

**Author:** ![MrSingh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrSingh](https://forums.unrealengine.com/u/MrSingh)\
**Post date:** [June 26, 2022, 7:27am UTC](https://forums.unrealengine.com/t/line-trace-by-channel-doesnt-work-in-c/391695/3 "2022-06-26T07:27:41Z")

</div>

GetWorld()-\>LineTraceSingleByChannel(outHit, startTraceLoc, endTraceLoc, ECollisionChannel::ECC\_Camera,QueryParams, FCollisionResponseParams());  
if(outHit.IsValidBlockingHit())  
{  
std::cout \<\< “I am hitting something \n”;  
}
