# Attach Object To Spline

**URL:** <https://forums.unrealengine.com/t/attach-object-to-spline/493571>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question, UE4-27\
**Created:** [February 2, 2022, 11:46pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571 "2022-02-02T23:46:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 2, 2022, 11:46pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/1 "2022-02-02T23:46:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![HAF-Blade](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/haf-blade/32/88718_2.png) [@HAF-Blade](https://forums.unrealengine.com/u/HAF-Blade)\
**Post date:** [February 2, 2022, 11:51pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/2 "2022-02-02T23:51:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 3, 2022, 1:58am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/3 "2022-02-03T01:58:16Z")

</div>

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/2/942b1011fbcdbed196c4418333d17aced7959f3b.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 3, 2022, 2:03pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/4 "2022-02-03T14:03:51Z")

</div>

> [@Studio-237](#):
>
> but they all require it to function at run-time.

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:

> [@Curve a series of objects](https://forums.unrealengine.com/t/curve-a-series-of-objects/471428/10):
>
> Ah, I think I’m getting a better picture of this. I run this event in the Construction Script: Do note how the components are now added to a Static Mesh Component array so we can keep track of them. This allows me to preview the result in the world and manipulate the spline any way I need: [[Image from Gyazo]](https://gyazo.com/9c3d8a05cc689cd21f87fdf830c5f26f) The arrows are not aware they’re attached to a spline, they will not follow it. The Construction Scripts actually executes every frame and recreates everything from scr…

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.

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 3, 2022, 2:39pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/5 "2022-02-03T14:39:31Z")

</div>

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](https://youtu.be/ZVApE4w3ltw?t=1249)]. I want to control my coaster on the track.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 3, 2022, 2:46pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/6 "2022-02-03T14:46:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 3, 2022, 3:13pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/7 "2022-02-03T15:13:44Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/2/8/62841f5900d00035d2b55a86bf04c52ae201ba5c.png)

May seem crude but that’s the gist.

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 4, 2022, 12:01am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/8 "2022-02-04T00:01:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 4, 2022, 12:18am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/9 "2022-02-04T00:18:24Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/0/e/d0e583f7cf0858fbc39b45755ee170014ac5bbff.png)

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 4, 2022, 12:35am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/10 "2022-02-04T00:35:02Z")

</div>

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

EVENT GRAPH (referenced from your BP code):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/f/6af184ecbde72937729ab6cf84bcd602e1edd021.png)

CONSTRUCTION SCRIPT:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/5/c757ab913411d11b9249fb7a290fd7c083c9b5d2.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 4, 2022, 9:19am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/11 "2022-02-04T09:19:38Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/4/3c46e91b8553a7261b4821933431ef6877325ede.png)

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/5/0d508145a69eb8780f34bcfc98b6b87254fca405.png)

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/2/f/b2fd558114d69a974c4bec0cfec8c2ab380d9b04.png)

- 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!

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 5, 2022, 2:15am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/12 "2022-02-05T02:15:20Z")

</div>

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.

 ![add cars](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/d/18d6459dc6d4ef1c6d6990935a9cac9b4f992e5b.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 6, 2022, 11:27am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/13 "2022-02-06T11:27:48Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/4/1/b415ffd3f25f4d0b062f4f2c63497a858245577b.png)

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

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 7, 2022, 11:55pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/14 "2022-02-07T23:55:10Z")

</div>

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/e/16e36de8a849a0e20d0caf4e3f5241d45ccdbce9.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/0/e/40ef71721e173fff49d0252129e2c705cba9ab04.jpeg)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/c/a/9ca4ed88523a946225ec20946e3ac88dc83ee3a1.jpeg)

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 8, 2022, 1:18am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/15 "2022-02-08T01:18:56Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/f/eff440e0147b2c027737190c3250afd4673dd0a0.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/c/3/ec349627421be124453f5f68120046209c6e35eb.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 8, 2022, 8:14am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/16 "2022-02-08T08:14:54Z")

</div>

> [@Studio-237](#):
>
> 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.

Could you double check these:

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/6/4a64b61cea72c1a68fb601cc1cee98812b71f624.png)

Constant Velocity should produce this behaviour:

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/c/7bc893f753c9a8bc67525a1b6b9d1edfdf206cf6.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 8, 2022, 8:51am UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/17 "2022-02-08T08:51:15Z")

</div>

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/f/3/4f36294225a1b943b6f641ea5156fc8f6bf450e2.png)

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

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 8, 2022, 8:32pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/18 "2022-02-08T20:32:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Studio-237](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/studio-237/32/604339_2.png) [@Studio-237](https://forums.unrealengine.com/u/Studio-237)\
**Post date:** [February 8, 2022, 8:35pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/19 "2022-02-08T20:35:20Z")

</div>

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.

 ![dfg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/7/7078b290fed8aa4260801d2a0846aa2dbc70a416.png)

 ![unknown](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/e/e6e623fec69f5613d82a82795c9f4ca57472d99e.png)

 ![unknown](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/9/359f50044d4e9a8ba4e33be1911cce14fbdf7089.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 8, 2022, 8:55pm UTC](https://forums.unrealengine.com/t/attach-object-to-spline/493571/20 "2022-02-08T20:55:30Z")

</div>

> [@Studio-237](#):
>
> My last bit of annoying million question

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?

[Next page](https://forums.unrealengine.com/t/attach-object-to-spline/493571.md?page=2)
