# Multiple instanced meshes along a spline

**URL:** <https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956>\
**Category:** Blueprint\
**Tags:** UE-5, unreal-engine, Blueprint, question\
**Created:** [May 16, 2023, 7:29pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956 "2023-05-16T19:29:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 7:29pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/1 "2023-05-16T19:29:23Z")

</div>

How can you have numerous instaced meshes moving along a spline? I want to create some tank treads. I have a spline BP and a Mesh BP that moves along it, it works great but I’m not sure how to add more instances to it.

 ![5b75150101d80c2a3c6aa74df3a70b38](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/1/2/b126cd0dc96a5a8034f24cc4672eda679e9f5c2b.png)

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [May 16, 2023, 8:00pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/2 "2023-05-16T20:00:30Z")

</div>

Need more info. What are the other instances doing? Do you want them to follow alongside the other instances (maybe offset a little). Or do you want the other instances to have their own location along the spline?

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 8:05pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/3 "2023-05-16T20:05:36Z")

</div>

Sorry that’s my bad, I’d like to have a closed looped spline (Tank Track Length) that can hold a certain amount of individual tank treads (Yet to be modelled, just using a small box for now) So I’d like to have the boxes slightly offset from each other other, all the way along the spline and rotating around it.

Essentially I’m trying to recreate this - [Unreal Engine 4 Tank Track Гусеницы для Танка - YouTube](https://www.youtube.com/watch?v=Yiu7KBESXZM&t=23s)

Red being the spline and direction of rotation, black being a few of the moving pieces

![Untitled](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/2/2c262c7c64be291502fe1cfd479a9d5dc3d3ef0e.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:** [May 16, 2023, 8:09pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/5 "2023-05-16T20:09:55Z")

</div>

Would this work for you:

> [@Move multiple actors along spline](https://forums.unrealengine.com/t/move-multiple-actors-along-spline/437200/7):
>
> Here’s a simplified (compared to yours) script I’d use were I to push numerous actors along a spline: [[Image from Gyazo]](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.

Does not really matter if these are actors, static meshes or ISM instances. Should work for anything with a transform. You could store offsets in an additional array since you cannot really conveniently store that data in an instance itself.

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 8:20pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/7 "2023-05-16T20:20:18Z")

</div>

I think it might do, I’m a little stuck on a couple of pieces though, What is the “AllCars” variable type? And how did you get the “Car Offset” to show in the SpawnActor node?

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [May 16, 2023, 8:29pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/8 "2023-05-16T20:29:01Z")

</div>

You could use the BP you have now. You’d need to set SplineREF as an array and do a Get All Actors of Class (should probably use tags). Have each BP tread have a variable that stores its own TimeToComplete variable. You’ll need to increment them all. Or just set these as offsets from the main TimeToComplete variable. Your choice.

Then just do a For Each on the array of SlineREF’s in MoveObject event.

If these are instanced meshes… I think you can store custom data on each. So you could store the time offset there.

edit: I think the hard part will be keeping the treads linked together as they rotate around the front and back wheels.

edit2: Actually, you can just add the time offset as you iterate. You just need to store the time offset once. You’ll need to set it so the distance between each looks good to you.

---

<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:** [May 16, 2023, 8:32pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/9 "2023-05-16T20:32:39Z")

</div>

> [@Meshii](#):
>
> AllCars

These are the elements you wish to move. In your case, these would be the plates of the track. I assumed you’d be at least using Instanced Static Meshes for this.

> And how did you get the “Car Offset” to show in the SpawnActor node?

You can expose variables for the actor constructor to use like so:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/5/e55c5751c26b86bfd1b83be589f13fdf7a22e0b6.png)

But please do not make each plate _an actor_, that’s a performance killer. What I suggested is merely a _method_ for movement.

* * *

If you’re serious about tanks / vehicle sim, may I suggest you have a look at the some of the greatest threads out there:

> [@\[ASSETS\] \[OPEN SOURCE\] Tanks, tracks and N-wheeled vehicles](https://forums.unrealengine.com/t/assets-open-source-tanks-tracks-and-n-wheeled-vehicles/41018):
>
> Hi guys, I was working on a prototype of off-road tracked vehicle similar to this amphibious beast of engineering: [[- YouTube] ](https://www.youtube.com/watch?v=ky16Ac7Q7yU) It was obvious that I should look into PhysX’s tank implementation but I’ve decided that first I want to get my own implementation in blueprints, to better understand what kind of forces are involved in simulation and how far you have to go in respect to reference materials. Prototype started with a huge vehicle, supported by 10 wheels of 2 meter diamete…

Search anything by [BoredEngineer](https://forums.unrealengine.com/u/BoredEngineer), his t(h)reads (ehm!) should be pay-per-view, imho.

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 8:37pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/10 "2023-05-16T20:37:17Z")

</div>

Sorry I’m not the best at blueprints so I’m trying to figure it out 😃 I’ve got the car offset showing now but I’m a little lost on the AllCars variable, is that referencing the Tread Mesh BP that I have? Or is it something else entirely?

And that thread is amazing! That’s almost exactly what I’ve been struggling to find

---

<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:** [May 16, 2023, 8:42pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/11 "2023-05-16T20:42:54Z")

</div>

> Or is it something else entirely?

Something else - you will need a lot of little meshes, right? You’re moving many pieces along the spline.

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

Judging by this reference pic, you’d need about 30 or so. In your original pic:

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

You were attempting to move this entire actor. But you should be moving the many small links of the tank tread and make them glide along the spline. Think of this actor as of the entire tread that moves the small bits about.

* * *

The script you have there should be a separate actor. Something along the lines of:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/c/06ce263d640543ed01ba4375484a55dc0785a2fd.jpeg)

And the meshes could be instanced using this component. This actor represent a single tread and moves the plates / links.

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 8:50pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/12 "2023-05-16T20:50:27Z")

</div>

Right, I kinda see that. So I’ve got my BP of a single tread. (The one that gets spawned in the spawn actor node) I have my SplineBP (The one with all this code in) and inside SplineBP I have a Spline and an InstancedStaticMesh, set to my mesh. But I can’t connect the instanced static mesh get reference into the add array part

---

<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:** [May 16, 2023, 8:55pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/13 "2023-05-16T20:55:59Z")

</div>

All of the above should be in a single actor. There’s no reason to fetch the spline with Get Actor of Class. What if you have 2 treads (like in normal tank), it will not work anymore.

* * *

Start with something along the lines of:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/e/54e0049dc63a8d1d690e8abecf1b58d16c1e5cd8.png)

Now you have tread actor that spawns links. Once you have those, you can try moving them.

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 9:09pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/14 "2023-05-16T21:09:40Z")

</div>

Sorry for the slow reply, it crashed and had to remake it. So I’ve got all of that construction script in the same BP as the rest of it. But I’m still not sure what to put here.

![Untitled](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/b/5/6b5883079718d0a32c727b57b9de81d20591a1bf.jpeg)

---

<div class="post-metadata">

**Author:** ![AlienRenders](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AlienRenders](https://forums.unrealengine.com/u/AlienRenders)\
**Post date:** [May 16, 2023, 9:09pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/15 "2023-05-16T21:09:41Z")

</div>

@Everynone That’s pretty cool.

I was just thinking about how to keep each segment linked. If you set the pivot of each instance to one end and set X toward the other end, then you could figure out where the next segment’s location is and use a bit of trig to figure out the angle (similar to what Aim At does).

---

<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:** [May 16, 2023, 9:20pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/16 "2023-05-16T21:20:45Z")

</div>

As mentioned above, please do not spawn actors for links. This will be a performance catastrophy. The original thread I posted was dealing with a car traffic system where each element was a car actor.

See the example with the animation above. We’re adding instances to the `Instanced Static Mesh` component. If you decide to go for this method, you may want to take a dive and figure out how they actually work first.

> I was just thinking about how to keep each segment linked. If you set the pivot of each instance to one end and set X toward the other end, then you could figure out where the next segment’s location is and use a bit of trig to figure out the angle (similar to what Aim At does).

There may be no need for that, the spline has a bunch of data we can sample:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/8/1b88df191c22b6ce43d2a3c956753399dc0b8d33.png)

If the meshes are designed well and populating the spline densely enough, this may be ready to go as is.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/5/ce5168107a17d6df4d9ff62b618c73ad8a5c3de4.jpeg)

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 9:32pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/17 "2023-05-16T21:32:07Z")

</div>

Right I see what you meant now! Sorry about that, so the construction script is pretty much working (Something funky going on with the distances between each piece) and I’ve tried connecting it to the original movement script but it’s moving the whole piece along the spline now like in the gif, I think I just need to plug something into the “Set Actor Transform” target but it wont accept the instanced mesh.

[https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/1/33157345b94e4171b6487ea33081befc7ff1bfc5.mp4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/3/1/33157345b94e4171b6487ea33081befc7ff1bfc5.mp4)

---

<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:** [May 16, 2023, 9:35pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/18 "2023-05-16T21:35:28Z")

</div>

Looks like you moving the actor rather than the individual links. If the actor is moving, the spline is moving.

> Something funky going on with the distances between each piece

Tick `Use Constant Velocity` on the `Get Transform at Time` node. This will normalise distribution, as the distances between the spline points vary.

---

<div class="post-metadata">

**Author:** ![Meshii](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Meshii](https://forums.unrealengine.com/u/Meshii)\
**Post date:** [May 16, 2023, 9:38pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/19 "2023-05-16T21:38:13Z")

</div>

Originally I was using “Set Actor Transform” to move the SingularBP along the SplineBP but since it’s now within the same BP I can’t use set actor transform, what could I use to replace that, so that it only moves the instanced mesh?

---

<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:** [May 16, 2023, 9:40pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/20 "2023-05-16T21:40:54Z")

</div>

> [@Meshii](#):
>
> what could I use to replace that, so that it only moves the instanced mesh?

Construction Script where we create as many offsets as there are instances

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

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

The timeline is just 0-1 alpha. The `Dirty` flag is optional but a good optimisation practice.

---

<div class="post-metadata">

**Author:** ![Frenetic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frenetic/32/1142542_2.png) [@Frenetic](https://forums.unrealengine.com/u/Frenetic)\
**Post date:** [May 16, 2023, 9:43pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/21 "2023-05-16T21:43:03Z")

</div>

> [@Everynone](#):
>
> You could store offsets in an additional array since you cannot really conveniently store that data in an instance itself.

Could this not be done with custom-primitive-data?

---

<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:** [May 16, 2023, 9:44pm UTC](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956/22 "2023-05-16T21:44:25Z")

</div>

Maybe, **definitely** worth trying. It would be much, much faster, for sure. This ISM approach is, kind of, OK, at best. And absolutely horrible if you have like 20 tanks.

@IlIFreneticIlI If you every attempt it, do @me. I’ve only had good times with custom-primitive-data so far. It’s an underutilised feature.

I lie, I got badly burnt with HISM + custom primitive data combo in 4.26 where it would jumble instance indexes due to LODs swapping.

[Next page](https://forums.unrealengine.com/t/multiple-instanced-meshes-along-a-spline/1167956.md?page=2)
