My project is a road editor so I erase and redraw SplineMeshComponents VERY often.
Is there a cleaner way to update a SplineMeshComponent than calling
DestroyComponent() > AddSplineMeshsComponent() > SetStaticMesh() > SetMaterial() >
SetStartAndEnd() ?
Do i absolutely have to destroy the component every time ?
If you use SplineMeshComponents from your spline actor, they get destroyed on construction - when the spline moves or has points added/removed the construction is called and the whole object is remade.
You could make a system to add actors instead that have a SplineMeshComponent in them, then just update those transforms and start/end data but that’s pretty heavy handed…
If you’ve got collision disabled, it should be very fast anyway…
Yes that’s right, you can spawn an actor, attach it (or not) and add a SplineMeshComponent to that actor - it’s not the most efficient as you have so many actors, but it’s possible to do, you could make a system with an ActorPool of those SplineMeshComponent Actors and use them while creating your spline, then ‘bake’ it with it’s own spline mesh components when you’re finished maybe?