Movement along splines - where to keep spline data content?

I have a system I created quite some time ago with actors moving along splines, that get dynamically created. Everything works fine, but now revisting this again for a rework. Here I’m coming across an old issue I had at the time of making that system.

Problem: the moving actors have a spline component. If storing the spline data (points etc…) within that component itself, I had weird movement issues (actors flying away in kind of a spiral movement). While all waypoints were reported correctly when debugging, the movement was wrong. Must somehow be related to the spline being a child component of the actor it is controlling…

The only way I did get around that was to store the spline contents themselves in a separate “spline manager” actor placed in the level - and in the moving actors just reference the spline content stored in that actor. This was not a problem, because I needed some manager anyway.

Now having that manager actor with a Map of splines, key is name of the moving actor - I would like to get rid of that, because my feeling is, that this design is bad. I’d prefer to have a solution not requiring that separate storage and instead keep everything self contained within my moving actor class.

Any ideas, what I might have done wrong?

This is so interesting. I hope someone can answer this.

No step for mankind, but a giant leap for me :grin:

I found a very simple solution for the problem - how stupid have I been…

Just keep the world transform of the local spline component in a variable at BeginPlay of your moving actor.
Now when moving along the spline in Tick, simply change the Spine Components transform back to that value before attempting the SetActorTransform of the actor itself.

This way, the Spline Component is effectively not moved at all along with its actor, which keeps the spline point values unchanged - so having the same result as if using a separate actor for the spline within the level…

To me it sounds like the spline component is a child component of an actor being moved along it. I may be wrong though, but that would explain the weirdness.

What I would try is to simply get the spline component in the Blueprint node tree, and on BeginPlay (or Spawn, if you spawn it at runtime), I would call detach on it.

That way, the spline should end up still being part of the actor not not being moved with it. So that when you move your actor along the spline, you don’t move the spline with it.

1 Like

Hi Rawalanche, yes, exactly that’s the problem - moving along something, that’s influenced by our movement itself - leads to trouble.
Your suggestion is very good - something I did already try, because I also thought, that something not attached should not have movement. But for some reason, it did not work when I tried that.

Thanks so much for pointing again in this direction, which made me revisit this again - and now I found the mistake I made when using Detach - I need to use Keep World for the Rules (default is Keep Relative). Now it works like a charm and I can skip my brute force reset method. Code is getting shorter and smarter. Thanks so much for saving my day.

Yep, sorry, forgot to add that you may need to change the default rules. Fortunately you’ve been able to figure it yourself :slight_smile: