Hi everyone,
I’m trying to draw a line using an array of FVector
data points, and while the debug lines display correctly (as shown in the yellow and purple lines in the images), the Niagara system doesn’t display the path as expected. It displays correctly at the beginning for a very short time but then either doesn’t display or shows the giant swirls which seems to have tons of lines that loop back.
I have confirmed that the FVector
data is correctly passed to the Niagara system, by debugging the assigned values.
Issue:
- The
FVector
data is shown correctly via debug lines, but when assigning it to the Niagara system, it doesn’t render the path correctly. - I’ve confirmed the vector data is correct by printing it to the log.
Setup:
- I am using two Niagara components (
ReachableNiagaraComponent
andUnreachableNiagaraComponent
), and I’m trying to pass an array ofFVector
data to theReachableNiagaraComponent
via theSetNiagaraArrayVector
function.
Here’s the relevant code:
APlayerGizmos::APlayerGizmos(): ReachableNiagaraSystem(nullptr), UnreachableNiagaraSystem(nullptr), BaseDecalScale(),
ReachableNiagaraComponent(nullptr),
UnreachableNiagaraComponent(nullptr)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
// Create Niagara components as subobjects
ReachableNiagaraComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("ReachableNiagaraComponent"));
ReachableNiagaraComponent->SetupAttachment(RootComponent);
ReachableNiagaraComponent->SetAutoActivate(false);
ReachableNiagaraComponent->Deactivate();
UnreachableNiagaraComponent = CreateDefaultSubobject<UNiagaraComponent>(TEXT("UnreachableNiagaraComponent"));
UnreachableNiagaraComponent->SetupAttachment(RootComponent);
UnreachableNiagaraComponent->SetAutoActivate(false);
UnreachableNiagaraComponent->Deactivate();
}
void APlayerGizmos::DrawReachablePath(const TArray<FVector>& InNavPath, float InDistanceAgentAbleToTravel)
{
// Calculate the reachable path points
TArray<FVector> ReachablePathPoints;
bool bReachedMaxDistance = false;
CalculateReachablePathPoints(InNavPath, InDistanceAgentAbleToTravel, ReachablePathPoints, bReachedMaxDistance);
// Debug length of reachable path
UE_LOG(LogTemp, Log, TEXT("PLAYER GIZMOS: Calculated Reachable Path Length: %d"), ReachablePathPoints.Num());
// Draw a debug path for reachable path
for (int32 i = 0; i < ReachablePathPoints.Num() - 1; ++i)
{
DrawDebugLine(
GetWorld(),
ReachablePathPoints[i] + FVector(0.0f, 0.0f, 10.0f),
ReachablePathPoints[i + 1] + FVector(0.0f, 0.0f, 10.0f),
FColor::Yellow,
false,
1.5f,
0,
2.0f
);
UE_LOG(LogTemp, Log, TEXT("PLAYER GIZMOS: Reachable Path Point: %s"), *ReachablePathPoints[i].ToString());
}
// Draw a debug path for the entire path
for (int32 i = 0; i < InNavPath.Num() - 1; ++i)
{
DrawDebugLine(
GetWorld(),
InNavPath[i] + FVector(0.0f, 0.0f, 50.0f),
InNavPath[i + 1] + FVector(0.0f, 0.0f, 50.0f),
FColor::Purple,
false,
1.5f,
0,
2.0f
);
}
// Debug the current 'TargetPath' Data Interface
TArray<FVector> DebugTargetPath =
UNiagaraDataInterfaceArrayFunctionLibrary::GetNiagaraArrayVector(
ReachableNiagaraComponent,
FName("TargetPath")
);
for (int32 i = 0; i < DebugTargetPath.Num(); ++i)
{
UE_LOG(LogTemp, Log, TEXT("PLAYER GIZMOS: Debug Target Path Point: %s"), *DebugTargetPath[i].ToString());
}
// Access the 'TargetPath' Data Interface
UNiagaraDataInterfaceArrayFunctionLibrary::SetNiagaraArrayVector(
ReachableNiagaraComponent,
FName("TargetPath"),
ReachablePathPoints
);
// Activate the Niagara component after setting the data
ReachableNiagaraComponent->Activate(true);
}
Has anyone experienced something similar with Niagara systems or encountered rendering issues when passing FVector
arrays? Any suggestions on what could be causing this discrepancy?
Thanks!