# Procedurally generated tunnel

I’m using this great asset → Curved World | VFX Shaders | Unity Asset Store

The asset is amazing!

I’m working on an endless runner and working on a solution to procedurally change curves. The asset accepts a float between max and min for the curve. So I would need to have a solution that finds the next value, and then maybe lerps to it. And also make sure that the pattern is not repeated. Sort of like procedurally creating a spline.

The game is inside a tunnel, and the tunnel bends left and right and up and down.

One possible solution I’m considering is to use Mathf.PerlinNoise. Does any one have any tips? Thank you!

Well, Perlin noise is continuous on both X and Y and in your case you’re curving in that same space, and as long as your able to put constraints into how exactly a Perlin noise value translates into that asset’s sense of curvature, you’re fine. Sounds like a great plan to me!

I would advise you only to express the transformation in as many parameters as you can think of, just to make the conversion as expressive and creative as possible. Think of configurable Perlin noise scale and offset (and obviously velocity in your case), but also of multilayered Perlin noises maybe for increased difficulty, or smaller, less pronounced changes in curvature (so-called noise lacunarity).

Oh and I’ve just seen the asset also twists, obviously, well that’s an extra dimension for your case (rotation on Z) that you need to account for. I can advise you to also introduce an another set of Perlin noise (or a different offset), and an intensity multiplier with which you can regulate how pronounced the twists should be. For example.

1 Like

Does that asset accept a continuum of curvatures going down the entire length of the tunnel?

Or is the entire tunnel drawn with a specific twist?

If the former, then adding noise in the spatial Z+ direction might make a very interesting twisty tunnel.

If the latter then changing the param over time might have a very jarring long hallway twist, if it accumulates going forward.

1 Like

H

Thank you for your advice. Do know of any tutorial or article that would help? I’ve never used Perlin noise out side of creating top down maps/worlds. I’m trying to get my head around how to use it this way.

I’m not going to be twisting the tunnels or bending up and down and left and right. Thank you.

The asset will twist and or curve/bend an object. It is a vertex shader. In my game, the camera/player doesn’t move. I move the tunnel and the shader draws it with a curve. The horizontal and vertical curving or bending is done via changing a float. I want to curve the tunnel in a procedural way, up and down and left and right. I wont be using the twist.

I’m certain that was a typo

There are a lot of tuts about Perlin lying around. I can’t pick any one particularly special. Just find one that talks about its usage in Unity, and not about the actual Perlin noise or how it’s generated, or it will fly over your head.

‍♂️ Yes! And thanks for the advise!