# LineTraceSingleByChannel didn't check AI Character for outhit

**URL:** <https://forums.unrealengine.com/t/linetracesinglebychannel-didnt-check-ai-character-for-outhit/1303205>\
**Category:** C++\
**Tags:** linetrace, unreal-engine, question, CPP\
**Created:** [September 19, 2023, 11:15am UTC](https://forums.unrealengine.com/t/linetracesinglebychannel-didnt-check-ai-character-for-outhit/1303205 "2023-09-19T11:15:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![606014](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@606014](https://forums.unrealengine.com/u/606014)\
**Post date:** [September 19, 2023, 11:15am UTC](https://forums.unrealengine.com/t/linetracesinglebychannel-didnt-check-ai-character-for-outhit/1303205/1 "2023-09-19T11:15:11Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/5/3258a1c6819db2f14ba43da5c0835f8d45f0b8c0.jpeg)

Hello, I’m developing a FPS game that shoots with a hitscan technique based on LineTrace. If the first factor hit through LineTrace is AI, I want to halve the HP of AI, but the factor is never detected. Instead, elements in the level design are detected. Can you tell me what the problem is?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/6/4a672efab60e7a445a9c31dfd01fc9e6cd2893ab.jpeg)

```auto
if (GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, CollisionParams))
	{
		if (OutHit.bBlockingHit)
		{
			UE_LOG(LogTemp, Warning, TEXT("OutHit: %s"), *(OutHit.GetActor()->GetName()));
			if (OutHit.GetActor()->GetName() == "AI") {
				AprojectCharacter* AI = Cast<AprojectCharacter>(OutHit.GetActor());
				AI->CalculateHP(-10);
				UE_LOG(LogTemp, Warning, TEXT("AI HP: %d"), AI->HP);
			}
		}
	}
}

```
