C++ Troubleshooting Line Generation

In my project, several “planets” are connected to each other via “links,” which are determined based on up to three pointers in each planet. Lines representing the links should be drawn at runtime. My current code correctly prints out the X location of each planet (for verification) but does not draw the lines for the links. How can I draw the lines linking the systems as specified by the three link pointers? I’m very new to UE4 and have been reading on this subject for hours with no progress.

void ASystemLinks::BeginPlay()
{
	Super::BeginPlay();
	UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlanet_Base::StaticClass(), FoundActors);

	for (int k = 0; k < FoundActors.Num(); k++) {
		auto element = FoundActors[k];
		APlanet_Base* planet = Cast<APlanet_Base>(element);
		FVector planetLoc = planet->GetActorTransform().GetTranslation();

		//this method may draw duplicate lines 
		if (planet->link1 != nullptr) {
			FVector linkLoc = planet->link1->GetActorTransform().GetTranslation();
			GetWorld()->LineBatcher->DrawLine(planetLoc, linkLoc, FColor(255,255,255), SDPG_World, 100.f, 0);
			UE_LOG(LogTemp, Warning, TEXT("%d"), (int)linkLoc.X);
		}
		if (planet->link2 != nullptr) {
			FVector linkLoc = planet->link2->GetActorTransform().GetTranslation();
			GetWorld()->LineBatcher->DrawLine(planetLoc, linkLoc, FColor(255, 255, 255), SDPG_World, 100.f, 0);
			UE_LOG(LogTemp, Warning, TEXT("%d"), (int)linkLoc.X);
		}
		if (planet->link3 != nullptr) {
			FVector linkLoc = planet->link3->GetActorTransform().GetTranslation();
			GetWorld()->LineBatcher->DrawLine(planetLoc, linkLoc, FColor(255, 255, 255), SDPG_World, 100.f, 0);
			UE_LOG(LogTemp, Warning, TEXT("%d"), (int)linkLoc.X);
		}
	}	
}

Unless I’m mistaken, the last parameter you’re using in the DrawLine function defines the lifetime of your lines. I believe that by passing a value of zero the editor immediately deletes your lines. Instead of zero try providing a higher value (eg 180)

I played with several options for that parameter, but had no luck with anything I put in there. I was hoping a zero value would indicate an infinite lifespan. Just tried 180, but no luck. Unless it flashes in and out of the level faster than I can see…

Upon closer inspection, the lines may be drawn for a frame or two (very hard to tell, but it looks like they flash in and out very quickly). They flash for the same duration regardless of the size of the lifetime parameter.a

The code should be moved to the tick section as the lines must be redrawn every frame. If anyone knows how to set these lines to persistent after initial construction in BeginPlay(), please comment. For now, moving to tick() works.