Download

Randomly Generated Rolling Terrain

Hi,

This may be something very simple, but I am a total novice to game development AND UE4.

I’m working on a skill-based mobile game that will require randomly generated terrain to avoid. In theory the terrain should be bound by a set of “standard” min-max height values with a sine wave shape; but occasionally throw in an “abnormal” large mountain to avoid. I’m starting with the Sidescroller Blueprint (3D assets with a 2D viewport) and I’ll be keeping the floating player in a box as the randomly terrain is generated on the right side off-screen and moves to the left. And I just feel the need to make this clear… there are no flying animals that dodge pipes in this game, or even close to that gameplay mechanic.

Can someone help me get started?

In case this matters: I have a gameplay concept where the character picks up a power-up that allows you to drill through the mountain. is this type of Worms-esque destruction possible with UE4?

Thank you,
Sanborn

Possible? Impossible?

What your wanting to do is possible in UE4 but with just BP? I dunno.

There are a two threads in this forum based on Procedural Generation for terrain. I think this is what you are looking for? However, those threads are working on a tile based system, and to create seamless generation is another layer of complexity on that tile-based logic.

Map Generator- Please Critique! - Blueprint Visual Scripting - Unreal Engine Forums!
Procedurally Generated Map Lag - Blueprint Visual Scripting - Unreal Engine Forums

Quite possible. Not trivial but also not hard at all.

For start do not try to make endless runner game, this is unnecessary layer of complication for prototype. You can add it later.

You have 2 choices either generate whole level randomly in construction script. But this is hard to debug and test, debugging is not working for construction scripts, and there are quirks that you need go around. Also this way is not easy to move into endless runner later. Works kind of like second way but its done in construction and its easier on lights and shadow.

Second way is that you just spawn blueprint outside right edge of screen. Make single blueprint terrain segment that has fixed width. Then calculate its number (ie. 0-X or 0-Y world coordinate / width) from that create random seed, initialize stream and use random from stream to generate details of segment. This way every time you generate that segment at given location it will be exactly same. Store as many pointers to those blueprints as you need, kill ones that are past left edge of screen.

Also another good idea is to make generating segments from seed, then one evening you get box of beer and go trough all seeds write down ones you like, put them all in array and use only those to generate levels. So your level will be just array of seeds that you use to make segments. You will have more control over level this way. It was done for “River Raid” game in 1982, so its quite old idea.

Even more complicated idea is to make few types of segment. Like 1,2,3 floors, pits/hills in middle, left, right, type of background etc. Then you write down seed and segment type.

This all is quite simple, only one problem is lighting which needs to be dynamic, so you should not have more than 2-3 lights. Also turn off shadows for everything you can.