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

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.

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

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.