Download

DrawDebugLine drawn line persists even with BPersistent set to false

I’m using UE5 and mostly blueprints. I moved a particular function from an Actor Component to C++ and have been trying to expand its functionality. This function is a Tick function and I’m running into issues with drawing a debug line.

I’m trying to use the DrawDebugLine and it draws in-game, but I can’t get it to not persist. I set BPersistentLines to false but the lines remain on screen and clutter it up. Any ideas what I am doing wrong?

void UWire::WireScans()
{
	FHitResult Hit(ForceInit);
	FCollisionQueryParams collisionParams;
	collisionParams.AddIgnoredActor(startActor);
	collisionParams.AddIgnoredActor(endActor);

	for (int i = 0; i < wirePoints.Num()-1; i++) {
		FVector startPoint = wirePoints[i];//Set Start Point of Trace to location of i
		FVector endPoint = wirePoints[i+1]; ///Set End Point of Trace to location of i+1

		GetWorld()->LineTraceSingleByChannel(Hit, startPoint, endPoint, ECC_WorldDynamic, collisionParams);

		DrawDebugLine(GetWorld(),startPoint, endPoint, FColor::Blue, false, 0.0f, true, 2.0f);
	}
}

Seems to be a bug, i’ve tested on 4-27 with wirePoints = {0.0.0; 60.0.0; 60.60.0; 0.60.0} and added location of movable actor and lines are not president.

void AMyGameModeBase::WireScans(FVector location)
{
	

	for (int i = 0; i < wirePoints.Num(); i++) {
		FVector startPoint = location + wirePoints[i];

		FVector endPoint;
		//
	
		if (i == wirePoints.Num() - 1)
		{
			endPoint = location + wirePoints[0]; 
		}
		else
		{
			endPoint = location + wirePoints[i + 1]; 
		}
	
		DrawDebugLine(GetWorld(), startPoint, endPoint, FColor::Blue, false, 0.0f, true, 2.0f);
	}
}

you can try to set LifeTime to -1.F. Value third from end in DrawDebugLine which now 0.0f and you can try simple constant data set as I did