EDIT:
Thanks, but still problems
My modified code:
ASpline::ASpline()
{
AddedSplineMeshes.Empty();
}
void ASpline::SetupSpline() {
//Remove existing meshes
for (int32 i = 0; i < AddedSplineMeshes.Num(); i++){
AddedSplineMeshes*->DetachFromParent();
AddedSplineMeshes*->UnregisterComponent();
}
AddedSplineMeshes.Empty();
for (int32 i = 0; i < Spline->GetNumberOfSplinePoints() - 1; i++)
{
USplineMeshComponent* tempMesh = ConstructObject<USplineMeshComponent>(USplineMeshComponent::StaticClass(), this);
AddedSplineMeshes.Add(tempMesh);
tempMesh->CreationMethod = EComponentCreationMethod::UserConstructionScript;
tempMesh->SetMobility(EComponentMobility::Static);
tempMesh->AttachParent = Spline;
tempMesh->SetStaticMesh(SplineMesh);
// Code to set curves
tempMesh->RegisterComponent();
}
}
The entire thing disappears when the game runs, no matter what I do.
If I check ‘Hidden in game’, then the shadows immediately disappear in editor, so I know that isn’t the problem since it’s easy to see if that is turned on/off.
Edit2: I didn’t have UPROPERTY() for my array. Adding it made them appear in game too. Thanks!