void AZipLine::SetupSpline() { //int32 SplineMeshComponentsNum = AddedSplineMeshComponents.Num(); //remove spline mesh components to get to Spline->GetNumSplinePoints() - 1 /*for (int32 Index = SplineMeshComponentsNum - 1; Index >= Spline->GetNumberOfSplinePoints() - 1; --Index) { AddedSplineMeshComponents[Index]->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform); AddedSplineMeshComponents[Index]->UnregisterComponent(); }*/ //remove entries from array or make room for new components //AddedSplineMeshComponents.SetNum(Spline->GetNumberOfSplinePoints() - 1, true); //construct spline mesh components to get to Spline->GetNumSplinePoints() - 1 //previously constructed components will remain in the AddedSplineMeshComponents array unchanged for (int32 Index = 0; Index < Spline->GetNumberOfSplinePoints() - 1; Index++) { USplineMeshComponent* SplineMesh = NewObject<USplineMeshComponent>(this, USplineMeshComponent::StaticClass()); FVector pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd; Spline->GetLocalLocationAndTangentAtSplinePoint(Index, pointLocationStart, pointTangentStart); Spline->GetLocalLocationAndTangentAtSplinePoint(Index + 1, pointLocationEnd, pointTangentEnd); SplineMesh->SetStartAndEnd(pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd); if (RopeMesh) { SplineMesh->SetStaticMesh(RopeMesh); } SplineMesh->SetCollisionProfileName(FName("OverlapOnlyPawn")); SplineMesh->CreationMethod = EComponentCreationMethod::UserConstructionScript; SplineMesh->SetMobility(EComponentMobility::Movable); SplineMesh->SetupAttachment(Spline); SplineMesh->bCastDynamicShadow = false; } RegisterAllComponents(); }
void cEntityMgrRL::RegisterComponentTypes() { RegisterAllComponents(*this); }