# Move multiple actors along spline

**URL:** <https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200>\
**Category:** Blueprint\
**Tags:** actor, tag, spline-mesh-componen, unreal-engine, Spline, Blueprint, question\
**Created:** [November 7, 2018, 2:41pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200 "2018-11-07T14:41:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iscreamdeye](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Iscreamdeye](https://forums.unrealengine.com/u/Iscreamdeye)\
**Post date:** [November 7, 2018, 2:41pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/1 "2018-11-07T14:41:53Z")

</div>

So for my project i need to spawn multiple actors along spline.  
With i have managed to work only one of the actors rest of them are standing still.  
Where am i wrong?

 ![258795-7.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/9/b/d9be0885adf6d548bd1c5ea1802517151d5f90ce.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:** [November 7, 2018, 4:31pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/2 "2018-11-07T16:31:33Z")

</div>

You’re getting just 1 element from the array - (Get 0). Do a _ForEachLoop_ instead of _Get_. But you need to do it during Timeline’s update.

Also, you should execute _GetAllActorsOfClass_ (if you must) from the _Completed_ pin of the first loop - otherwise, it’s pure chaos.

---

<div class="post-metadata">

**Author:** ![richarmearup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@richarmearup](https://forums.unrealengine.com/u/richarmearup)\
**Post date:** [February 2, 2021, 1:44pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/3 "2021-02-02T13:44:06Z")

</div>

Hey there, did you ever manage to solve this? I am facing a similar issue - my actors spawn along the spline but do not move.

---

<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 2, 2021, 2:29pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/4 "2021-02-02T14:29:15Z")

</div>

Perhaps attach a screenshot showing your attempt and folks will be happy to poke holes in it.

---

<div class="post-metadata">

**Author:** ![richarmearup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@richarmearup](https://forums.unrealengine.com/u/richarmearup)\
**Post date:** [February 4, 2021, 2:18am UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/5 "2021-02-04T02:18:30Z")

</div>

Hey Everynone - good advice!

I am quite new to coding so no doubt there will be many a hole to be poked. Please see code attached - it seems to generate vehicles along the spline no problem, but they don’t move when I hit play.

---

<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, 2021, 10:00am UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/6 "2021-02-04T10:00:54Z")

</div>

Atm, you’re attempting to move the _Multi Vehicle Generator_ actor along the spline. The child actor component cars are not attached to this actor as you flagged it as _manual_. That’s what I’ve gathered.

How is it supposed to work in the long run?

- cars move independently on each spline and the distance between them can change?

or

- the entire spline moves with all cars attached?

---

<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, 2021, 10:04am UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/7 "2021-02-04T10:04:55Z")

</div>

Here’s a simplified (compared to yours) script I’d use were I to push numerous actors along a spline:

 ![328859-screenshot-4.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/6/416295d0650fd599b0ca70e78ff59036b88d8a12.jpeg)

[![Image from Gyazo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/4/8/34836e372d641671daaf735d82c1d45aebc8bada.gif)](https://gyazo.com/cc07a1a805a8c28391c561dbac6e5380)

Essentially, each car stores an offset. We animate another spline offset using a timeline, add both, and  
reposition the car. An optional `Modulo` wraps the value so we get perpetual motion.

---

<div class="post-metadata">

**Author:** ![richarmearup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@richarmearup](https://forums.unrealengine.com/u/richarmearup)\
**Post date:** [February 4, 2021, 1:24pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/8 "2021-02-04T13:24:15Z")

</div>

Thanks for your reply, Everynone, it is much appreciated. In the long run, the idea was to have blueprint cars (blueprint code makes the wheels rotate) follow a spline with fixed spacing i.e. the distance between them can’t change - essentially what you have produced with the Cubes in the gif above.

Apologies for the following newbish questions, if they make any sense at all:

1. Is this Blueprint script for your Spline referencing another Actor Blueprint, called ‘A Car’, which just has a static mesh component (a Cube) and stores the Car Offset float?
2. I am a little confused as to how you connected the Array Element output from the For Each Loop to the Car Offset float (highlighted in image attached) - I get an error saying _The static mesh actor object reference is not compatible…_
3. Do you need to connect the ADD Array to the Timeline (highlighted in my screenshot) or does the Timeline need something connected to the Play input?

Thanks a lot for this help, I’ve spent days trying to crack this!

---

<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, 2021, 2:25pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/9 "2021-02-04T14:25:32Z")

</div>

> Is this Blueprint script for your Spline referencing another Actor  
> Blueprint, called ‘A Car’, which just  
> has a static mesh component (a Cube)  
> and stores the Car Offset float?

- the `aCar` is an actor with a Static Mesh Component and a Car Offset variable
- the blueprint owning the Spline spawns a bunch of those actors and keeps their references in an array (it’s very similar to what you do, but instead of having a Child Actor Spawn a car, I spawn it directly)

> I am a little confused as to how you connected the Array Element output  
> from the For Each Loop to the Car  
> Offset float (highlighted in image  
> attached) - I get an error saying The  
> static mesh actor object reference is  
> not compatible…

Each car actor has its own _Static Mesh_ and a _Car Offset_ variable (_Instance Editable_ and _Exposed on Spawn_ so the pin shows up when you attempt to spawn the actor - can be seen on _Spawn Actor from Class_ node)

The array holds all the actors. The _ForEach_ loop nodes iterates over the elements of that array. This way, as the Timeline updates, you get a chance to access every aCar, its components and variables, and update them if necessary.

> Do you need to connect the ADD Array  
> to the Timeline (highlighted in my  
> screenshot) or does the Timeline need  
> something connected to the Play input?

Sadly, I see no screenshot attached. The Timeline can be set to _Autoplay_ and / or _Loop_ (note the extra icons on the node) or be triggered manually. Here, it’s automatic - there’s a panel above the track graph inside the timeline editor with a bunch of switches.

---

<div class="post-metadata">

**Author:** ![richarmearup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@richarmearup](https://forums.unrealengine.com/u/richarmearup)\
**Post date:** [February 16, 2021, 2:43pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/10 "2021-02-16T14:43:32Z")

</div>

Meant to say, thanks a mil for the help Everynone - your advice did the trick! 😃

---

<div class="post-metadata">

**Author:** ![thefrozenfish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thefrozenfish](https://forums.unrealengine.com/u/thefrozenfish)\
**Post date:** [December 7, 2021, 5:30pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/11 "2021-12-07T17:30:51Z")

</div>

Hello @Everynone

Cheers for sharing this! This is exactly what ive been looking for and found this after much searching in forums. A bit of a BP newbie here and I have managed to replicate your carGen BP shared above without any errors. But sadly when I play it, nothing moves and only one car (cube) is generated on point[0] of the spline. Please see attached, screenshots of my BPs, gameplay and timelines. Please if anyone can tell what I have done wrong here, would be much appreciated!  
Thanks in advance!  
🙂

 ![353395-timeline-0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/5/875b62e28712a7304f1f2cbd9f8dca094d69b40f.jpeg)

---

<div class="post-metadata">

**Author:** ![thefrozenfish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thefrozenfish](https://forums.unrealengine.com/u/thefrozenfish)\
**Post date:** [December 7, 2021, 5:30pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/12 "2021-12-07T17:30:58Z")

</div>

Hello @Everynone and all

Cheers for sharing this! This is exactly what ive been looking for and found this after much searching in forums. A bit of a BP newbie here and I have managed to replicate your carGen BP shared above without any errors. But sadly when I play it, nothing moves and only one car (cube) is generated on point[0] of the spline. Please see attached, screenshots of my BPs, gameplay and timelines. Please if anyone can tell what I have done wrong here, would be much appreciated!  
Thanks in advance!  
🙂

 ![353399-onplay.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/e/8fe69d1950eb20c6c4e95174afc7c4103f29c601.jpeg)

 ![353396-bp01.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/d/85dc19a84efd8b9260dc01e89c325eea14f73ddc.jpeg)

 ![353397-bp02.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/f/28f7770f3facc3ba3ac9891c3930e42b42a285db.jpeg)

 ![353395-timeline-0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/7/5/875b62e28712a7304f1f2cbd9f8dca094d69b40f.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:** [December 7, 2021, 6:05pm UTC](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/13 "2021-12-07T18:05:45Z")

</div>

What is your `Cars` variable set to?

Also, this should be `modulo` not `division`:

![353699-screenshot-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/7/847c4a31fde2313dfdec96f146b0369575b578bb.png)

**That’s probably it.**
