Cannot attach SplineMeshComponents to Scene, even though they're both movable

I have set both my SplineMeshComponents, my Spline, my RootComponent(Which is named Scene) all to movable and yet I keep receiving an Warning:

"Warning AttachTo: '/Game/UEDPIE_0_TestLevel.TestLevel:PersistentLevel.BP_VRMotionController_C_1.Scene' is not static  (in blueprint "BP_VRMotionController"), cannot attach '/Game/UEDPIE_0_TestLevel.TestLevel:PersistentLevel.BP_VRMotionController_C_1.SplineMeshComponent_1' which is static to it. Aborting."

And I have set just about everything to movable that would affect the spline meshes’ and yet it keeps giving me this warning. I would appreciate any help on why this warning keeps coming up, because when you get over a thousand warnings for this one issue its difficult to ignore.

//Creating the variable for the spline mesh
		USplineMeshComponent* newSpline = NewObject<USplineMeshComponent>(this);
		
		//Setting other default values.
		newSpline->AttachToComponent(Scene, FAttachmentTransformRules::SnapToTargetIncludingScale);

		//This has to occur after creating a new object in the world.
		newSpline->RegisterComponentWithWorld(GetWorld());
		newSpline->RegisterComponent();

		//If the spline is static then it has errors when attaching
		newSpline->SetMobility(EComponentMobility::Movable);
		newSpline->SetRelativeLocation(FVector::ZeroVector);
		newSpline->SetRelativeRotation(FRotator::ZeroRotator);
		newSpline->SetRelativeScale3D(FVector(1.0f, 1.0f, 1.0f));

		//Setting the visual representation of the splineMeshes.
		newSpline->SetStaticMesh(SplineMesh);
		newSpline->SetMaterial(0, SplineMaterial);

		newSpline->SetStartTangent(FVector(100.0f, 0.0f, 0.0f));
		newSpline->SetEndPosition(FVector(100.0f, 0.0f, 0.0f));
		newSpline->SetEndTangent(FVector(100.0f, 0.0f, 0.0f));
		newSpline->SetForwardAxis(ESplineMeshAxis::X);
		newSpline->SetSplineUpDir(FVector(0.0f, 0.0f, 1.0f));
		newSpline->SetCollisionEnabled(ECollisionEnabled::NoCollision);

		splineMeshes.Add(newSpline);

Hey -

Where are you calling this code? When I create my spline component and declare its mobility as movable in my class constructor, I do not get any warnings about not being able to attach it to the root component. Can you provide additional details about how you’re setting up your actor / spline component?

Of course, I am calling this in a separate method/function that is used for updating an arc using splines. Here is the rest of that function:

void AVRMotionController::UpdateArcSpline(bool FoundValidLocation, TArray SplinePoints)
{
if (!FoundValidLocation)
{
SplinePoints.Empty();
SplinePoints.Add(ArcDirection->GetComponentLocation());
SplinePoints.Add((ArcDirection->GetForwardVector() * 20.0f) + ArcDirection->GetComponentLocation());
}

    	FVector Thing = FVector::ZeroVector;
    
    	for (int32 index = 0; index < SplinePoints.Num(); index++)
    	{
    		Thing = SplinePoints[index];
    		//Build a spline from all trace points. This generates tangets 
    		//we can use to build a smoothly curved spline mesh
    		ArcSpline->AddSplinePoint(Thing, ESplineCoordinateSpace::Local, true);
    	}
    
    	//Update the point type to create the curve
    	ArcSpline->SetSplinePointType(SplinePoints.Num(), ESplinePointType::CurveClamped, true);
    
    	for (int32 index = 0; index < ArcSpline->GetNumberOfSplinePoints() - 2; index++)
    	{

               //FILL IN THIS BLANK AREA WITH THE CODE FROM ABOVE
    
    		//Set the tangents and position to build slightly
    		//bend the cylinder. All cylinders combined 
    		//create a smooth arc.
    		newSpline->SetStartAndEnd
    		(
    			SplinePoints[index],
    			ArcSpline->GetTangentAtSplinePoint(index, ESplineCoordinateSpace::Local),
    			SplinePoints[index + 1],
    			ArcSpline->GetTangentAtSplinePoint(index + 1, ESplineCoordinateSpace::Local)
    		);
    	}

Hey -

The reason for the warning is that the root component (Scene) needs to be set to Static. If you set the Scene component’s mobility to Static, then the warning won’t appear for the SplineMeshComponent.

Cheers

1 Like

So I did that, and it pretty much broke my game. I tried a workaround which was create another Scene and have it under the root scene and parented it to that and set that to static and now I only get one warning vs the thousands of warnings that would flood the message log for every spline mesh I created. The reason is because that scene has to be static to attach to the root scene, but as I said before this breaks what I’m trying to do and this does exactly what I need so no point in trying to fix that one warning.

For those who are still looking for the answer of this question:

You have to set the mobility of your spline mesh component to match the root component’s mobility. In BP you can do it by selecting the “Add Spline Mesh Component” and changing the values in the details panel.

In code, you have to set the mobility of the spline you have created after this line:
USplineMeshComponent* newSpline = NewObject<USplineMeshComponent>(this);

Then you can attach it. You are welcome :slight_smile: