DrawDebugLine() Identifier Not Found

Hey guys,

Just trying to do a simple line trace here with a debug line, but it won’t build saying that DrawDebugLine() Identifier Not Found. What gives?


void ALifeCharacter::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);

	FVector CamLoc;
	FRotator CamRot;

	Controller->GetPlayerViewPoint(CamLoc, CamRot); // Get the camera position and rotation
	const FVector StartTrace = CamLoc; // trace start is the camera location
	const FVector Direction = CamRot.Vector();
	const FVector EndTrace = StartTrace + Direction * 200;

	// Perform trace to retrieve hit info
	FCollisionQueryParams TraceParams(FName(TEXT("WeaponTrace")), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = true;

	FHitResult Hit(ForceInit);
	if (GetWorld()->LineTraceSingle(Hit, StartTrace, EndTrace, ECC_WorldStatic, TraceParams))
	{
		AInventory* NewItem = Cast<AInventory>(Hit.GetActor()); // typecast to the item class to the hit actor
		if (bDrawDebugViewTrace)
		{
			DrawDebugLine(
				GetWorld(),
				StartTrace,
				EndTrace,
				FColor(255, 0, 0),
				false,
				3,
				0,
				1
			);
		}

		if (NewItem) // if we hit an item with the trace
		{
			this->PickUpItem(NewItem); // pick it up
		}
	}

}

Any help is appreciated. Thanks!

Did you include the header file?


#include "DrawDebugHelpers.h"

Sadly, this fixed it. I have much to learn. Thanks! :slight_smile:

For future viewers: If you ever get this error on anything, just google the name of the function, and look at the bottom of the API docs. Where it says header, copy everything after either the word public or just the entire thing into an include statement, like #include “whatever/you/copied/over”.