# Is it possible to procedurally "curve" a road in an endless runner, if the road meshes are reused?

**URL:** <https://forums.unrealengine.com/t/is-it-possible-to-procedurally-curve-a-road-in-an-endless-runner-if-the-road-meshes-are-reused/483586>\
**Category:** World Creation\
**Tags:** endless-runner, road, unreal-engine, Spline, procedural, Splines, question\
**Created:** [May 18, 2021, 9:40pm UTC](https://forums.unrealengine.com/t/is-it-possible-to-procedurally-curve-a-road-in-an-endless-runner-if-the-road-meshes-are-reused/483586 "2021-05-18T21:40:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_895c6cfb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_895c6cfb](https://forums.unrealengine.com/u/anonymous_user_895c6cfb)\
**Post date:** [May 18, 2021, 9:40pm UTC](https://forums.unrealengine.com/t/is-it-possible-to-procedurally-curve-a-road-in-an-endless-runner-if-the-road-meshes-are-reused/483586/1 "2021-05-18T21:40:42Z")

</div>

What I have -

I have an endless runner protoype that reuses the road meshes by hiding them, then teleporting them infront of the player, during tick. This is great but it currently only works for straight lines.

What I need -

I need to be able to dynamically “curve” the road. Have it turn left and right procedurally. In my mind, one potential solution would be to create splines procedurally during tick in front of the player, and then have the teleporting tunnels morph to the spline each time to teleport. However I have no idea if this is even possible, or which blueprints to look into.

Is there a way to do this fairly easily? Or is there any examples already on the internet of this kind of idea?

Thanks to anyone who has any pointers.

---

<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 19, 2021, 6:38am UTC](https://forums.unrealengine.com/t/is-it-possible-to-procedurally-curve-a-road-in-an-endless-runner-if-the-road-meshes-are-reused/483586/2 "2021-05-19T06:38:08Z")

</div>

> I need to be able to dynamically  
> “curve” the road. Have it turn left  
> and right procedurally. In my mind,  
> one potential solution would be to  
> create splines procedurally during  
> tick in front of the player, and then  
> have the teleporting tunnels morph to  
> the spline each time to teleport.  
> However I have no idea if this is even  
> possible, or which blueprints to look  
> into.

Very possible, quite common and not that difficult - especially that you have the pooling (reusing) bit already working. It can be done in real time, too but if you’re updating _hundreds_ of road tunnel pieces at the same time, the performance will not be great as this is somewhat computationally intentisivce. It’s more than ok if you need a dozen or so, though. But perhaps you only need several that the player _can_ see.

Look into **Spline Mesh Components** - they allow you to dynamically bend meshes along a spline:

[https://www.youtube.com/results?search\_query=spline+mesh+componen](https://www.youtube.com/results?search_query=spline+mesh+componen)

See if any of the videos look somewhat close to what you need. The general rule is the same:

- read a location and tangent at initial / next spline point
- apply that data to the spline mesh component
- the engine will automagically deform the mesh
- rinse and repeat for all point of the spline -1 (if you have 10 spline points, you’ll need 9 SMCs - but you can get away with fewer if they’re not all visible at the same time)

Do note that the system has its limitations, currently there’s no way to _consistently_ deform a single mesh along more than 1 spline segment. So if you have a long zig-zag path, you will need to use multiple meshes. This is usually desired anyway.
