No worries. I wrote up a huge post with snippets and screenshots but the forum wiped it
So it’s basically a TArray filled with “track pieces” (UPiece)
A struct of TArray and Name:
USTRUCT(BlueprintType) struct FPiecesStruct {
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<class UPiece*> ArrayOfPieces;
};
This is created as an Array variable in BP so I can have multiple TArrays, and then filled with my component UPiece (subclass of UStaticMeshComponent)
One of these Arrays is passed into the Intialise() BP node. When the method is called, I want it to pick out the UPiece entry from the TArray based on whichever Index it’s been given:
UPiece* NextPiece = MyPiecesSet.ArrayOfPieces[PiecesArrayInt[Index]];
Then I want to pass that to an Actor in the scene:
MyTrack->ArrangeNextPiece(NextPiece);
And that Actor should add it as a component:
void ATrack::ArrangeNextPiece(UPiece* NextPiece)
{
FName Name = FName();
UPiece* CurrentPiece = NewObject<UPiece>(this, Name, RF_NoFlags, NextPiece, false, nullptr);
CurrentPiece->SetWorldLocation(NextPieceLocation, false, 0, ETeleportType::None);
NextPieceLocation = CurrentPiece->GetSocketLocation(FName("Socket"));
CurrentPiece->SetWorldRotation(NextPieceRotation, false, 0, ETeleportType::None);
NextPieceRotation = CurrentPiece->GetSocketQuaternion(FName("Socket"));
}
This code hard-crashes on Play. I’m sure I’m just fundamentally misunderstanding the classes/pointers/etc.