Calculate Direction of Character for trace

Hey im just a little confused on how I should calculate my characters direction for my trace. I have a third person character im just wondering how my trace can always be in the front of the player. I want to calculate EndVector for the trace any ideas?
Thank You

    FHitResult testHitResult;
	UWorld* TheWorld = this->GetWorld();
	FVector testStartFVector = this->GetActorLocation() + FVector(50, 0, 0);
????FVector testEndFVector = ????????????????????
	FCollisionQueryParams TraceParams(TEXT("TraceOfAwesome"));

	if (TheWorld->LineTraceSingle(testHitResult, testStartFVector, testEndFVector, ECC_WorldStatic, TraceParams))
		UE_LOG(LogClass, Log, TEXT("Im Hitting Something"));

		UE_LOG(LogClass, Log, TEXT("Not Hitting anything"));
   const FColor White;
	DrawDebugLine(GetWorld(), testStartFVector, testEndFVector, White, false, -1.0f, 1, 5.0f);

get the rotation of the pawn, and convert to a vector, that will give you the direction.
At the end, it would be like this:
FVector testStartFVector = this->GetActorLocation() ; //directly from the center of the character.
FVector testEndFVector = testStartFVector + this->GetActorRotation().Vector() * TraceDistance;
Trace distance would be a float variable to control how far you want the trace to go.

try this testEndFVector =Pawn->GetActorLocation() + Pawn->GetActorRotation().RotateVector(Fvector(100.0f,0.f,0.f);


if (Character) Character->GetRootComponent()->GetForwardVector();


the math goes like this

start = player character location or a socket on the character / weapon

end = Start + ForwardVector * 100000;

or whatever you want trace length to be

then you plug start and end into your trace functions :slight_smile:

There’s a nifty node for this!