Attaching Spline at runtime

I have a USplineComponent* and associated USplineMeshComponent*s that i’ve instantiated with NewObject<> calls. They’ve been set up with meshs and material. They are owned by an object that is owned by a custom AGameModeBase, so they aren’t initially attached to anything. At a certain point during runtime, I want to attach the spline to an AActor and make it visible. I’ve called SetupAttachment to attach the USplineComponent to the actor’s Root Component, I’ve gone through the spline points and called SetStartAndEnd for each USplineMeshComponent, and I’ve called SetVisibility for both spline and spline meshes.

But I don’t see the spline. What else am I supposed to do?

I think you need to change the owner of the component first, before calling RegisterComponent(), SetupAttachment() etc.
Rename function provides this capability.

1 Like

Ah! You are correct sir, I needed to add both Rename and RegisterComponent for both my spline and spline meshes. Working as expected now, thanks!