Attach Object To Spline

I know there are tutorials to do this, but they all require it to function at run-time. Is there a way to control objects on a spline, in the viewport, and in the sequencer? I need to manually control and animate a roller coaster.

I really appreciate your help with this! I’m still rather new to Blueprints, so apologies for the hand holding.

Create a blueprint with a spline component and a spline mesh, drag the blueprint in your viewport and change it in the detail dialog.

Is there a way to make it follow the path of the spline? It doesn’t appear to be doing that. Also, the mesh is squashed. I’ll try to look into it in the meantime.

Wrap the distribution script in a function and use it the Construction Script - it will run outside PIE, in the editor. You can use the same function run-time, too.

Here’s a bunch of examples:

Image links are currently broken. We may need to wait until the migration is complete and wrinkles are ironed out. But YT if full of hot spline action.

There’s a working project link in the abovementioned thread that demonstrates it.

Much appreciated for the tip. Although I’m not sure that’s what I’m looking for. This video from 20:49 - 20:54 is the result I’m seeking after. [Maya Autodesk 2022 - Rigging - Roller Coaster - (Unreal Engine) - YouTube]. I want to control my coaster on the track.

You’d create a float offset variable, expose it. This variable controls position on the track. If you need to have more than 1 element, each element needs their own offset.

To be more specific, I run this in the Construction Script

May seem crude but that’s the gist.

1 Like

Thank you for the help, it’s much appreciated. The “MyCars” and “Car Offsets”, are those arrays? I’m still extremely new to BP’s.

Actually, I think I’ve got it. However, what sort of array does this need to be in order to plug into the “ADD”?

Okay, I think I’ve got it actually…but it’s not quite there. Is this correct?

EVENT GRAPH (referenced from your BP code):

CONSTRUCTION SCRIPT:

The construction script is my current spline that’s already set. I suppose the next step is just plugging in the “AddCars” function somewhere?

It’s here, a new graph will open after a double click. This part of the graph is executed when the editor creates the object. It will also run when you move or edit the actor in the viewport.

Also, any variables flagged as Instance Editable will be exposed for editing:

You get to control what values sliders permit and set their defaults, too.


[…]what sort of array does this need to be in order to plug into the “ADD”?

It’s about the type. Float is different from a Bool and they’re both very different from a Static Mesh. Think of it: what kind of data can this variable refer to?

  • hovering over pins tells you the expected type:

  • the variable that will store that reference should have the same type (simplifying a bit).

Instead of going through a long list and manually look up the pertinent type, you can promote pins to variables:

Handy and speeds things up!

I tried that, but I’ve noticed in yours you have a custom event in your construction script. But, there’s no way to add a custom event to the construction script, from what am I seeing. Am I missing something? This is how I’m doing it, based on what I’ve discovered and your recent tutorial.

I think I’m close. I just don’t know where to exactly plug things into.

You do not need the Game Mode bit - this was just to demonstrate variable promotion to get the correct type. Find the Construction Script node in the graph:

image

Pan around, it’s there and cannot be deleted. You can also press Home on the keyboard and the editor will pan onto it.

Ahh okay! Sorry. Yeah, I got it to work now. Apologies for the million questions, but is there a way to clamp the location of each mesh? I’ve noticed when moving the carts along the spline they bunch up or spread apart. Seems as if they’re going based on the curve.

I’m going to look into it myself, but any assistance would be appreciated.

I also can’t seem to get the cars to animate in sequencer, even after exposing the parameter in the blueprint, even though it’s keyed. Is there something I’m missing?

image

Could you double check these:

  • are you sure you’re adjusting Progress and not Spacing
  • perhaps we’re running with this unticked

Constant Velocity should produce this behaviour:

edit: judging by the previous screenshot, this is probably it:

You’d need to Expose the Variable to Cinematic, and you then can:

image

Admittedly, cinematography & sequencer are somewhat alien to me, not sure if I can be of any help. I’ll hang around to learn, though.

Ahhhh! of course. Thank you so much for your help. This whole project has been quite the learning curve, but I’ve learned a lot. I sincerely appreciate your help.

My last bit of annoying million questions would be, how do I use arrays to change the cars? I have 3 variations I need to use.

You’d think that. But answering builds up (brain) muscle memory. Things that work and things that don’t - both equally important.

how do I use arrays to change the cars? I have 3 variations I need to use.

What is the difference between the cars? The way they look? Or will they behave differently?